Store release_date on added movies
Needed so the frontend can sort lists by release date, not just by when they were added. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,7 +19,7 @@ class MovieController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $this->movieModel->add($data['user_id'], $data['tmdb_id'], $data['title'], $data['poster_path'] ?? null, $data['media_type'] ?? 'film');
|
$res = $this->movieModel->add($data['user_id'], $data['tmdb_id'], $data['title'], $data['poster_path'] ?? null, $data['media_type'] ?? 'film', $data['release_date'] ?? null);
|
||||||
echo json_encode(["success" => $res]);
|
echo json_encode(["success" => $res]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -9,10 +9,10 @@ class Movie {
|
|||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add($userId, $tmdbId, $title, $poster, $type) {
|
public function add($userId, $tmdbId, $title, $poster, $type, $releaseDate = null) {
|
||||||
// 1. On insère le film
|
// 1. On insère le film
|
||||||
$stmt = $this->db->prepare("INSERT INTO movies (user_id, tmdb_id, title, poster_path, media_type, is_common) VALUES (?, ?, ?, ?, ?, 0)");
|
$stmt = $this->db->prepare("INSERT INTO movies (user_id, tmdb_id, title, poster_path, media_type, release_date, is_common) VALUES (?, ?, ?, ?, ?, ?, 0)");
|
||||||
$stmt->execute([$userId, $tmdbId, $title, $poster, $type]);
|
$stmt->execute([$userId, $tmdbId, $title, $poster, $type, $releaseDate ?: null]);
|
||||||
|
|
||||||
// 2. On récupère l'ID du partenaire (supposons que tu as une table 'users' avec un champ 'partner_id')
|
// 2. On récupère l'ID du partenaire (supposons que tu as une table 'users' avec un champ 'partner_id')
|
||||||
$stmt = $this->db->prepare("SELECT partner_id FROM users WHERE id = ?");
|
$stmt = $this->db->prepare("SELECT partner_id FROM users WHERE id = ?");
|
||||||
|
|||||||
Reference in New Issue
Block a user