This commit is contained in:
Lars Behrends
2025-10-18 22:03:30 +02:00
parent f4c1cfc164
commit ca2d3a6960
45 changed files with 4827 additions and 326 deletions

View File

@@ -106,4 +106,64 @@ class AdultVideo extends Model
return $sourceData ? new Source($this->pdo, $sourceData) : null;
}
/**
* Get all actors associated with this adult video
*/
public function actors()
{
$stmt = $this->pdo->prepare("
SELECT a.*
FROM actors a
JOIN actor_adult_video aav ON a.id = aav.actor_id
WHERE aav.adult_video_id = :adult_video_id
ORDER BY a.name ASC
");
$stmt->execute(['adult_video_id' => $this->id]);
return $stmt->fetchAll(\PDO::FETCH_ASSOC);
}
/**
* Add an actor to this adult video
*/
public function addActor(int $actorId): bool
{
$stmt = $this->pdo->prepare("
INSERT IGNORE INTO actor_adult_video (adult_video_id, actor_id)
VALUES (:adult_video_id, :actor_id)
");
return $stmt->execute([
'adult_video_id' => $this->id,
'actor_id' => $actorId
]);
}
/**
* Remove an actor from this adult video
*/
public function removeActor(int $actorId): bool
{
$stmt = $this->pdo->prepare("
DELETE FROM actor_adult_video
WHERE adult_video_id = :adult_video_id AND actor_id = :actor_id
");
return $stmt->execute([
'adult_video_id' => $this->id,
'actor_id' => $actorId
]);
}
/**
* Update the cast field with actor names
*/
public function updateCastField(): bool
{
$actors = $this->actors();
$actorNames = array_column($actors, 'name');
$castString = implode(', ', $actorNames);
return $this->update($this->id, [
'cast' => $castString
]);
}
}