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:
2026-07-12 20:08:14 +02:00
parent a60d7bf69f
commit 5a64dc0395
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ class MovieController {
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]);
}
+3 -3
View File
@@ -9,10 +9,10 @@ class Movie {
$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
$stmt = $this->db->prepare("INSERT INTO movies (user_id, tmdb_id, title, poster_path, media_type, is_common) VALUES (?, ?, ?, ?, ?, 0)");
$stmt->execute([$userId, $tmdbId, $title, $poster, $type]);
$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, $releaseDate ?: null]);
// 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 = ?");