1
0
mirror of https://github.com/devfake/flox.git synced 2024-11-15 22:52:32 +01:00
flox/backend/app/Item.php
2016-11-28 08:48:12 +01:00

40 lines
747 B
PHP

<?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',
'original_title',
'poster',
'media_type',
'rating',
'released',
'created_at',
'genre',
];
public function episodes()
{
return $this->hasMany(Episode::class, 'tmdb_id', 'tmdb_id');
}
public function latestEpisode()
{
return $this->hasOne(Episode::class, 'tmdb_id', 'tmdb_id')
->orderBy('id', 'desc')
->where('seen', true)
->latest();
}
}