mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-02-05 11:09:33 -06:00
- this resolves some larastan property issues but in return has revealed quite a few issues with our castings and such. baseline has been regenerated so we can work through them. The properties in docblocks are in order and match everything in DB schema wise.
139 lines
4.7 KiB
PHP
139 lines
4.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\Factories\HasFactory;
|
|
use App\Enums\Occupation;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* App\Models\Movie.
|
|
*
|
|
* @property int $id
|
|
* @property string|null $tmdb_id
|
|
* @property string|null $imdb_id
|
|
* @property string $title
|
|
* @property string $title_sort
|
|
* @property string|null $original_language
|
|
* @property int|null $adult
|
|
* @property string|null $backdrop
|
|
* @property string|null $budget
|
|
* @property string|null $homepage
|
|
* @property string|null $original_title
|
|
* @property string|null $overview
|
|
* @property string|null $popularity
|
|
* @property string|null $poster
|
|
* @property string|null $release_date
|
|
* @property string|null $revenue
|
|
* @property string|null $runtime
|
|
* @property string|null $status
|
|
* @property string|null $tagline
|
|
* @property string|null $vote_average
|
|
* @property int|null $vote_count
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
* @property string|null $trailer
|
|
*/
|
|
class Movie extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $guarded = [];
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<Genre>
|
|
*/
|
|
public function genres(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Genre::class);
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<Person>
|
|
*/
|
|
public function people(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Person::class, 'credits');
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<Credit>
|
|
*/
|
|
public function credits(): \Illuminate\Database\Eloquent\Relations\HasMany
|
|
{
|
|
return $this->hasMany(Credit::class);
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<Person>
|
|
*/
|
|
public function directors(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Person::class, 'credits')
|
|
->wherePivot('occupation_id', '=', Occupation::DIRECTOR->value);
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<Company>
|
|
*/
|
|
public function companies(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Company::class);
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<Collection>
|
|
*/
|
|
public function collection(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Collection::class)->take(1);
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<Recommendation>
|
|
*/
|
|
public function recommendations(): \Illuminate\Database\Eloquent\Relations\HasMany
|
|
{
|
|
return $this->hasMany(Recommendation::class, 'movie_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<Movie>
|
|
*/
|
|
public function recommendedMovies(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
{
|
|
return $this->belongsToMany(__CLASS__, Recommendation::class, 'movie_id', 'recommendation_movie_id', 'id', 'id');
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<Torrent>
|
|
*/
|
|
public function torrents(): \Illuminate\Database\Eloquent\Relations\HasMany
|
|
{
|
|
return $this->hasMany(Torrent::class, 'tmdb', 'id')->whereHas('category', function ($q): void {
|
|
$q->where('movie_meta', '=', true);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany<TorrentRequest>
|
|
*/
|
|
public function requests(): \Illuminate\Database\Eloquent\Relations\HasMany
|
|
{
|
|
return $this->hasMany(TorrentRequest::class, 'tmdb', 'id')->whereHas('category', function ($q): void {
|
|
$q->where('movie_meta', '-', true);
|
|
});
|
|
}
|
|
}
|