Files
UNIT3D-Community-Edition/app/Models/Tv.php
HDVinnie 472c820f99 update: UNIT3D linting
- github action updated with new ruleset in pint.json
- codebase linted with new ruleset
- contributors can now run `./vendor/bin/pint`
- action workflow will auto correct any lint issues upon commit/opened pull request
2023-02-02 08:02:34 -05:00

82 lines
2.3 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 Tv extends Model
{
protected $guarded = [];
public $table = 'tv';
protected $hidden = ['created_at', 'updated_at'];
/**
* Has Many Torrents.
*/
public function torrents(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(Torrent::class, 'tmdb', 'id')->whereHas('category', function ($q): void {
$q->where('tv_meta', '=', true);
});
}
public function seasons(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(Season::class)
->oldest('season_number');
}
public function persons(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(Person::class);
}
public function cast(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(Cast::class, 'cast_tv', 'cast_id', 'tv_id');
}
public function crew(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(Crew::class, 'crew_tv', 'person_id', 'tv_id');
}
public function genres(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(Genre::class);
}
public function creators(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(Person::class);
}
public function networks(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(Network::class);
}
public function companies(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(Company::class);
}
public function recommendations(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(Recommendation::class, 'tv_id', 'id');
}
}