2016-10-10 10:57:39 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Laravel\Scout\Searchable;
|
|
|
|
|
|
|
|
class Item extends Model {
|
|
|
|
|
|
|
|
// Uncomment this if you are using Laravel Scout.
|
|
|
|
//use Searchable;
|
|
|
|
|
|
|
|
public $timestamps = false;
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
'tmdb_id',
|
|
|
|
'title',
|
2016-11-23 16:24:34 +01:00
|
|
|
'original_title',
|
2016-10-10 10:57:39 +02:00
|
|
|
'poster',
|
2016-11-24 11:52:10 +01:00
|
|
|
'media_type',
|
2016-10-10 10:57:39 +02:00
|
|
|
'rating',
|
|
|
|
'released',
|
|
|
|
'created_at',
|
2016-10-17 10:57:42 +02:00
|
|
|
'genre',
|
2016-10-10 10:57:39 +02:00
|
|
|
];
|
2016-11-28 08:48:12 +01:00
|
|
|
|
|
|
|
public function episodes()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Episode::class, 'tmdb_id', 'tmdb_id');
|
|
|
|
}
|
|
|
|
|
2016-12-17 16:59:59 +01:00
|
|
|
public function alternativeTitles()
|
|
|
|
{
|
|
|
|
return $this->hasMany(AlternativeTitle::class, 'tmdb_id', 'tmdb_id');
|
|
|
|
}
|
|
|
|
|
2016-11-28 08:48:12 +01:00
|
|
|
public function latestEpisode()
|
|
|
|
{
|
|
|
|
return $this->hasOne(Episode::class, 'tmdb_id', 'tmdb_id')
|
|
|
|
->orderBy('id', 'desc')
|
|
|
|
->where('seen', true)
|
|
|
|
->latest();
|
|
|
|
}
|
2016-10-10 10:57:39 +02:00
|
|
|
}
|