lots of progress
This commit is contained in:
@@ -32,6 +32,32 @@ class Movie extends Model
|
||||
'release_date' => 'date'
|
||||
];
|
||||
|
||||
public function wasListedBy(string $listSlug, User $user)
|
||||
{
|
||||
$mediaList = MediaList::where('slug', $listSlug)->where('user_id', $user->id)->first();
|
||||
|
||||
if ($mediaList) {
|
||||
$mediaListItem = MediaListItem::where('media_list_id', $mediaList->id)
|
||||
->where('item_id', $this->id)
|
||||
->where('item_type', 'movie')
|
||||
->first();
|
||||
|
||||
return !empty($mediaListItem);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function ratingBy(User $user)
|
||||
{
|
||||
$rating = Rate::where('user_id', $user->id)
|
||||
->where('item_id', $this->id)
|
||||
->where('item_type', 'movie')
|
||||
->first();
|
||||
|
||||
return $rating ? $rating->rate : null;
|
||||
}
|
||||
|
||||
public function director()
|
||||
{
|
||||
return $this->belongsToMany(Person::class, 'movie_cast', 'movie_id', 'person_id')
|
||||
|
||||
Reference in New Issue
Block a user