mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-02-13 07:00:12 -06:00
update: only include companies/networks with torrents in mediahub
This commit is contained in:
@@ -42,7 +42,12 @@ class CompanySearch extends Component
|
||||
#[Computed]
|
||||
final public function companies(): \Illuminate\Pagination\LengthAwarePaginator
|
||||
{
|
||||
return Company::withCount('tv', 'movie')
|
||||
return Company::query()
|
||||
->withCount([
|
||||
'movie' => fn ($query) => $query->has('torrents'),
|
||||
'tv' => fn ($query) => $query->has('torrents'),
|
||||
])
|
||||
->where(fn ($query) => $query->whereHas('movieTorrents')->orWhereHas('tvTorrents'))
|
||||
->when($this->search !== '', fn ($query) => $query->where('name', 'LIKE', '%'.$this->search.'%'))
|
||||
->oldest('name')
|
||||
->paginate(30);
|
||||
|
||||
@@ -42,7 +42,11 @@ class NetworkSearch extends Component
|
||||
#[Computed]
|
||||
final public function networks(): \Illuminate\Pagination\LengthAwarePaginator
|
||||
{
|
||||
return Network::withCount('tv')
|
||||
return Network::query()
|
||||
->withCount([
|
||||
'tv' => fn ($query) => $query->has('torrents'),
|
||||
])
|
||||
->whereHas('tvTorrents')
|
||||
->when($this->search !== '', fn ($query) => $query->where('name', 'LIKE', '%'.$this->search.'%'))
|
||||
->oldest('name')
|
||||
->paginate(30);
|
||||
|
||||
@@ -54,4 +54,20 @@ class Company extends Model
|
||||
{
|
||||
return $this->belongsToMany(Tv::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<Torrent, $this>
|
||||
*/
|
||||
public function movieTorrents(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Torrent::class, 'company_movie', 'movie_id', 'company_id', 'id', 'tmdb')->whereRelation('category', 'movie_meta', '=', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<Torrent, $this>
|
||||
*/
|
||||
public function tvTorrents(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Torrent::class, 'company_tv', 'tv_id', 'company_id', 'id', 'tmdb')->whereRelation('category', 'tv_meta', '=', true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,4 +54,12 @@ class Network extends Model
|
||||
{
|
||||
return $this->belongsToMany(Movie::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<Torrent, $this>
|
||||
*/
|
||||
public function tvTorrents(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Torrent::class, 'network_tv', 'tv_id', 'network_id', 'id', 'tmdb')->whereRelation('category', 'tv_meta', '=', true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user