25 lines
447 B
PHP
25 lines
447 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class MediaListItem extends Model
|
|
{
|
|
protected $fillable = [
|
|
'media_list_id',
|
|
'item_id',
|
|
'item_type',
|
|
'tmdb_id',
|
|
];
|
|
|
|
public function item()
|
|
{
|
|
if ($this->item_type == 'movie') {
|
|
return $this->hasOne(Movie::class, 'id', 'item_id');
|
|
}
|
|
|
|
return $this->hasOne(Show::class, 'id', 'item_id');
|
|
}
|
|
}
|