Files
UNIT3D-Community-Edition/app/Models/Episode.php
2020-10-28 17:07:09 -04:00

68 lines
1.7 KiB
PHP

<?php
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author HDVinnie <hdinnovations@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Episode extends Model
{
protected $guarded = [];
protected $orderBy = 'order';
protected $orderDirection = 'ASC';
public $table = 'episodes';
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function season()
{
return $this->belongsTo(Season::class)
->orderBy('season_id')
->orderBy('episode_id');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function person()
{
return $this->belongsToMany(Person::class);
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function cast()
{
return $this->belongsToMany(Cast::class)
->orderBy('order');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function crew()
{
return $this->belongsToMany(Crew::class, 'crew_episode', 'person_id', 'episode_id');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function guest_star()
{
return $this->belongsToMany(GuestStar::class, 'episode_guest_star', 'person_id', 'episode_id');
}
}