This commit is contained in:
2025-02-10 01:58:12 +02:00
parent 25d99e7b72
commit 87bbfc33d3
242 changed files with 38662 additions and 99 deletions
+10 -1
View File
@@ -6,5 +6,14 @@ use Illuminate\Database\Eloquent\Model;
class Topic extends Model
{
//
protected $table = 'forum_topics';
protected $fillable = [
'name',
'slug',
'status',
'category_id',
'thread_id',
'user_id',
];
}
+3
View File
@@ -6,6 +6,9 @@ use Illuminate\Database\Eloquent\Model;
class Image extends Model
{
public const TYPE_POSTER = 'posters';
public const TYPE_BACKDROP = 'backdrops';
protected $fillable = [
'aspect_ratio',
'height',
-8
View File
@@ -75,14 +75,6 @@ class ItemToFetchJobs extends Model
'tmdb_id',
'item_id',
'type',
'remaining_jobs',
'jobs',
];
protected function casts(): array
{
return [
'remaining_jobs' => 'array',
];
}
}
+58 -2
View File
@@ -36,6 +36,44 @@ class Show extends Model
'vote_count',
];
protected $casts = [
'first_air_date' => 'date',
'last_air_date' => 'date',
'languages' => 'array',
];
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', 'show')
->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', 'show')
->first();
return $rating ? $rating->rate : null;
}
public function externalIds()
{
return $this->hasOne(ExternalId::class, 'entity_id', 'id')
->where('external_ids.entity_type', 'show');
}
public function castList()
{
return $this->belongsToMany(Person::class, 'show_cast', 'show_id', 'person_id');
@@ -46,9 +84,27 @@ class Show extends Model
return $this->belongsToMany(Person::class, 'show_crew', 'show_id', 'person_id');
}
public function images()
public function images(string $type = 'posters')
{
return $this->belongsToMany(Image::class, 'show_images', 'show_id', 'image_id');
if ($type === Image::TYPE_POSTER) {
return $this->belongsToMany(Image::class, 'show_images', 'show_id', 'image_id')
->where('type', Image::TYPE_POSTER);
}
return $this->belongsToMany(Image::class, 'show_images', 'show_id', 'image_id')
->where('type', '=', Image::TYPE_BACKDROP);
}
public function posters()
{
return $this->belongsToMany(Image::class, 'show_images', 'show_id', 'image_id')
->where('type', Image::TYPE_POSTER);
}
public function backdrops()
{
return $this->belongsToMany(Image::class, 'show_images', 'show_id', 'image_id')
->where('type', '=', Image::TYPE_BACKDROP);
}
public function videos()