From c38d1a0ed49be74e2ee9d57b4dc09489abce3cca Mon Sep 17 00:00:00 2001 From: stiti Date: Mon, 10 Jun 2024 17:14:38 +0200 Subject: [PATCH] Commit de louay --- .../application/controllers/Playlists.php | 18 ++++ .../application/models/Model_playlist.php | 9 ++ .../application/views/artiste_details.php | 82 +++++++++++-------- 3 files changed, 73 insertions(+), 36 deletions(-) diff --git a/CodeIgniter-3.1.13/application/controllers/Playlists.php b/CodeIgniter-3.1.13/application/controllers/Playlists.php index d41ec45..a6c0763 100644 --- a/CodeIgniter-3.1.13/application/controllers/Playlists.php +++ b/CodeIgniter-3.1.13/application/controllers/Playlists.php @@ -341,6 +341,24 @@ class Playlists extends CI_Controller { redirect('playlists/view/' . $playlist_id); } + + public function add_track_to_playlist($track_id, $playlist_id) { + // Vérifier si l'utilisateur est connecté + if (!$this->session->userdata('user_id')) { + redirect('utilisateur/connexion'); + } + + // Récupérer le song_id à partir du track_id + $song_id = $this->Model_playlist->get_song_id_by_track_id($track_id); + + $data = array( + 'playlist_id' => $playlist_id, + 'song_id' => $song_id + ); + $this->Model_playlist->add_song_to_playlist($data); + + redirect('playlists/view/' . $playlist_id); + } public function add_artist($playlist_id) { diff --git a/CodeIgniter-3.1.13/application/models/Model_playlist.php b/CodeIgniter-3.1.13/application/models/Model_playlist.php index 80a329d..34e884b 100644 --- a/CodeIgniter-3.1.13/application/models/Model_playlist.php +++ b/CodeIgniter-3.1.13/application/models/Model_playlist.php @@ -121,6 +121,15 @@ class Model_playlist extends CI_Model { return $this->db->get()->result(); } + public function get_song_id_by_track_id($track_id) { + $this->db->select('songId'); + $this->db->from('track'); + $this->db->where('id', $track_id); + $query = $this->db->get(); + $result = $query->row_array(); + return $result['songId']; + } + public function add_album_to_playlist($data) { return $this->db->insert('playlist_album', $data); } diff --git a/CodeIgniter-3.1.13/application/views/artiste_details.php b/CodeIgniter-3.1.13/application/views/artiste_details.php index 58c8b21..85e4b62 100644 --- a/CodeIgniter-3.1.13/application/views/artiste_details.php +++ b/CodeIgniter-3.1.13/application/views/artiste_details.php @@ -1,22 +1,21 @@ -
-

Détails de l'artiste name; ?>

-

Genre le plus utilisé par l'artiste : genreName; ?>

-

Albums de name; ?>

- +
+ \ No newline at end of file