mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
...
This commit is contained in:
@@ -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
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user