From 5e6eeadc61ac634b5b19bbe3cd4e26efcefe666b Mon Sep 17 00:00:00 2001 From: Roardom Date: Wed, 24 Jan 2024 04:51:38 +0000 Subject: [PATCH 001/307] fix: case insensitivity duplicate checking in keyword upsert We were deduping keywords, but we were only checking for exact duplicates. Now we check for case insensitive duplicates, and make sure to update the duplicates on upsert instead of treating the upsert as an insert. Fixes #3412. --- app/Helpers/TorrentTools.php | 5 ++++- app/Http/Controllers/API/TorrentController.php | 2 +- app/Http/Controllers/TorrentController.php | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Helpers/TorrentTools.php b/app/Helpers/TorrentTools.php index 41e18199fb..895972ce87 100644 --- a/app/Helpers/TorrentTools.php +++ b/app/Helpers/TorrentTools.php @@ -203,6 +203,9 @@ public static function anonymizeMediainfo(?string $mediainfo): ?string */ public static function parseKeywords(string $text): array { - return array_filter(array_unique(array_map('trim', explode(',', $text)))); + $keywords = array_filter(array_map('trim', explode(',', $text))); + + // unique keywords only (case insensitive) + return array_values(array_intersect_key($keywords, array_unique(array_map('strtolower', $keywords)))); } } diff --git a/app/Http/Controllers/API/TorrentController.php b/app/Http/Controllers/API/TorrentController.php index 27a36786a2..6f86a02b9c 100644 --- a/app/Http/Controllers/API/TorrentController.php +++ b/app/Http/Controllers/API/TorrentController.php @@ -288,7 +288,7 @@ public function store(Request $request): \Illuminate\Http\JsonResponse } foreach (collect($keywords)->chunk(intdiv(65_000, 2)) as $keywords) { - Keyword::upsert($keywords->toArray(), ['torrent_id', 'name'], []); + Keyword::upsert($keywords->toArray(), ['torrent_id', 'name']); } // check for trusted user and update torrent diff --git a/app/Http/Controllers/TorrentController.php b/app/Http/Controllers/TorrentController.php index ed5df2ce20..9e34c122ab 100644 --- a/app/Http/Controllers/TorrentController.php +++ b/app/Http/Controllers/TorrentController.php @@ -221,7 +221,7 @@ public function update(UpdateTorrentRequest $request, int $id): \Illuminate\Http } foreach (collect($keywords)->chunk(65_000 / 2) as $keywords) { - Keyword::upsert($keywords->toArray(), ['torrent_id', 'name'], []); + Keyword::upsert($keywords->toArray(), ['torrent_id', 'name']); } $category = $torrent->category; @@ -420,7 +420,7 @@ public function store(StoreTorrentRequest $request): \Illuminate\Http\RedirectRe } foreach (collect($keywords)->chunk(intdiv(65_000, 2)) as $keywords) { - Keyword::upsert($keywords->toArray(), ['torrent_id', 'name'], []); + Keyword::upsert($keywords->toArray(), ['torrent_id', 'name']); } // Cover Image for No-Meta Torrents From c21dcd1a26dea08ada3a5ba32032524f8ff51ef7 Mon Sep 17 00:00:00 2001 From: Roardom Date: Wed, 24 Jan 2024 04:58:52 +0000 Subject: [PATCH 002/307] fix: indonesia vs india localization typo --- lang/en/regions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/en/regions.php b/lang/en/regions.php index f0211d0ef2..f46e73d234 100644 --- a/lang/en/regions.php +++ b/lang/en/regions.php @@ -114,7 +114,7 @@ 'HUN' => 'Hungary', 'IDN' => 'Indonesia', 'IMN' => 'Isle of Man', - 'IND' => 'Indonesia', + 'IND' => 'India', 'IOT' => 'British Indian Ocean Territory', 'IRL' => 'Ireland', 'IRN' => 'Iran', From fe3107610445fefe560d0b3613ac9ed038bbd5a3 Mon Sep 17 00:00:00 2001 From: Roardom Date: Wed, 24 Jan 2024 08:03:05 +0000 Subject: [PATCH 003/307] Reapply "Merge pull request #3380 from Roardom/livewire-types" This reverts commit b4a9dfea8b08b30baec8bffc14d85ff1741a539a. --- app/Http/Livewire/AnnounceSearch.php | 15 +- app/Http/Livewire/ApikeySearch.php | 15 +- app/Http/Livewire/AttachmentUpload.php | 3 + app/Http/Livewire/AuditLogSearch.php | 9 + app/Http/Livewire/BackupPanel.php | 6 + app/Http/Livewire/BlockIpAddress.php | 3 + app/Http/Livewire/CollectionSearch.php | 5 +- app/Http/Livewire/Comment.php | 10 +- app/Http/Livewire/Comments.php | 13 +- app/Http/Livewire/CompanySearch.php | 5 +- app/Http/Livewire/FailedLoginSearch.php | 22 +- .../Livewire/ForumCategoryTopicSearch.php | 18 +- app/Http/Livewire/ForumTopicSearch.php | 18 +- app/Http/Livewire/GiftLogSearch.php | 19 +- app/Http/Livewire/HistorySearch.php | 19 +- app/Http/Livewire/InviteLogSearch.php | 19 +- app/Http/Livewire/LaravelLogViewer.php | 19 +- app/Http/Livewire/MissingMediaSearch.php | 21 +- app/Http/Livewire/NetworkSearch.php | 5 +- app/Http/Livewire/NoteSearch.php | 6 + app/Http/Livewire/NotificationSearch.php | 16 +- app/Http/Livewire/PasskeySearch.php | 15 +- app/Http/Livewire/PeerSearch.php | 19 +- app/Http/Livewire/PersonCredit.php | 10 +- app/Http/Livewire/PersonSearch.php | 5 +- app/Http/Livewire/PostSearch.php | 6 + app/Http/Livewire/RsskeySearch.php | 15 +- app/Http/Livewire/SimilarTorrent.php | 44 +- app/Http/Livewire/SubscribedForum.php | 3 + app/Http/Livewire/SubscribedTopic.php | 3 + app/Http/Livewire/SubtitleSearch.php | 19 +- app/Http/Livewire/ThankButton.php | 4 +- app/Http/Livewire/TicketSearch.php | 19 +- app/Http/Livewire/Top10.php | 2 +- app/Http/Livewire/TopicPostSearch.php | 8 +- app/Http/Livewire/TopicSearch.php | 23 +- app/Http/Livewire/TorrentRequestSearch.php | 66 +- app/Http/Livewire/TorrentSearch.php | 100 ++- app/Http/Livewire/TvSearch.php | 5 +- app/Http/Livewire/UserActive.php | 21 +- app/Http/Livewire/UserNotes.php | 3 + app/Http/Livewire/UserResurrections.php | 19 +- app/Http/Livewire/UserSearch.php | 19 +- app/Http/Livewire/UserTorrents.php | 24 +- app/Http/Livewire/UserUploads.php | 24 +- app/Http/Livewire/UserWarnings.php | 20 +- app/Http/Livewire/WarningLogSearch.php | 19 +- app/Http/Livewire/WatchlistSearch.php | 16 +- app/Traits/CastLivewireProperties.php | 102 +++ app/Traits/LivewireSort.php | 28 + phpstan-baseline.neon | 710 ------------------ .../views/livewire/torrent-search.blade.php | 52 +- 52 files changed, 626 insertions(+), 1063 deletions(-) create mode 100644 app/Traits/CastLivewireProperties.php create mode 100644 app/Traits/LivewireSort.php diff --git a/app/Http/Livewire/AnnounceSearch.php b/app/Http/Livewire/AnnounceSearch.php index 4c544c6db1..63e5a36ecf 100644 --- a/app/Http/Livewire/AnnounceSearch.php +++ b/app/Http/Livewire/AnnounceSearch.php @@ -14,6 +14,7 @@ namespace App\Http\Livewire; use App\Models\Announce; +use App\Traits\LivewireSort; use Livewire\Component; use Livewire\WithPagination; @@ -22,6 +23,7 @@ */ class AnnounceSearch extends Component { + use LivewireSort; use WithPagination; public int $perPage = 50; @@ -35,7 +37,7 @@ class AnnounceSearch extends Component public string $sortDirection = 'desc'; /** - * @var array + * @var array */ protected $queryString = [ 'page' => ['except' => 1], @@ -73,17 +75,6 @@ final public function getAnnouncesProperty(): \Illuminate\Contracts\Pagination\L ->paginate($this->perPage); } - final public function sortBy(string $field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } - final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { return view('livewire.announce-search', [ diff --git a/app/Http/Livewire/ApikeySearch.php b/app/Http/Livewire/ApikeySearch.php index 36ce156238..7eec4da507 100644 --- a/app/Http/Livewire/ApikeySearch.php +++ b/app/Http/Livewire/ApikeySearch.php @@ -15,6 +15,7 @@ use App\Models\Apikey; use App\Models\User; +use App\Traits\LivewireSort; use Livewire\Component; use Livewire\WithPagination; @@ -23,6 +24,7 @@ */ class ApikeySearch extends Component { + use LivewireSort; use WithPagination; public string $username = ''; @@ -36,7 +38,7 @@ class ApikeySearch extends Component public int $perPage = 25; /** - * @var array + * @var array */ protected $queryString = [ 'username' => ['except' => ''], @@ -70,15 +72,4 @@ final public function render(): \Illuminate\Contracts\View\View|\Illuminate\Foun 'apikeys' => $this->apikeys, ]); } - - final public function sortBy(string $field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } } diff --git a/app/Http/Livewire/AttachmentUpload.php b/app/Http/Livewire/AttachmentUpload.php index 1f04335e04..244e4552d7 100644 --- a/app/Http/Livewire/AttachmentUpload.php +++ b/app/Http/Livewire/AttachmentUpload.php @@ -58,6 +58,9 @@ final public function upload(): void $this->dispatchBrowserEvent('success', ['type' => 'success', 'message' => 'Ticket Attachment Uploaded Successfully!']); } + /** + * @return \Illuminate\Database\Eloquent\Collection + */ final public function getAttachmentsProperty(): \Illuminate\Database\Eloquent\Collection { return Ticket::find($this->ticket)->attachments; diff --git a/app/Http/Livewire/AuditLogSearch.php b/app/Http/Livewire/AuditLogSearch.php index 0145485790..9c1895658e 100644 --- a/app/Http/Livewire/AuditLogSearch.php +++ b/app/Http/Livewire/AuditLogSearch.php @@ -38,6 +38,9 @@ class AuditLogSearch extends Component public string $sortDirection = 'desc'; + /** + * @var array + */ protected $queryString = [ 'username' => ['except' => ''], 'modelName' => ['except' => ''], @@ -53,6 +56,9 @@ final public function updatedPage(): void $this->emit('paginationChanged'); } + /** + * @return string[] + */ final public function getModelNamesProperty() { $modelList = []; @@ -71,6 +77,9 @@ final public function getModelNamesProperty() return $modelList; } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getAuditsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { $audits = Audit::with('user') diff --git a/app/Http/Livewire/BackupPanel.php b/app/Http/Livewire/BackupPanel.php index 6eedb7e0d5..2f88780357 100644 --- a/app/Http/Livewire/BackupPanel.php +++ b/app/Http/Livewire/BackupPanel.php @@ -32,6 +32,9 @@ class BackupPanel extends Component { protected $listeners = ['refreshBackups' => '$refresh']; + /** + * @return array + */ final public function getBackupStatusesProperty(): array { return BackupDestinationStatusFactory::createForMonitorConfig(config('backup.monitor_backups')) @@ -59,6 +62,9 @@ final public function getActiveDiskProperty(): ?string return null; } + /** + * @return array + */ final public function getDisksProperty(): array { return collect($this->backupStatuses) diff --git a/app/Http/Livewire/BlockIpAddress.php b/app/Http/Livewire/BlockIpAddress.php index 060c47c1e2..98abf153b4 100644 --- a/app/Http/Livewire/BlockIpAddress.php +++ b/app/Http/Livewire/BlockIpAddress.php @@ -27,6 +27,9 @@ class BlockIpAddress extends Component public int $perPage = 25; + /** + * @var array + */ protected $queryString = [ 'page' => ['except' => 1], 'perPage' => ['except' => ''], diff --git a/app/Http/Livewire/CollectionSearch.php b/app/Http/Livewire/CollectionSearch.php index 0820936226..aee86cfa60 100644 --- a/app/Http/Livewire/CollectionSearch.php +++ b/app/Http/Livewire/CollectionSearch.php @@ -21,7 +21,7 @@ class CollectionSearch extends Component { use WithPagination; - public $search = ''; + public string $search = ''; final public function updatedPage(): void { @@ -33,6 +33,9 @@ final public function updatingSearch(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getCollectionsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Collection::withCount('movie') diff --git a/app/Http/Livewire/Comment.php b/app/Http/Livewire/Comment.php index 4232cf9106..1bcbb09e9c 100644 --- a/app/Http/Livewire/Comment.php +++ b/app/Http/Livewire/Comment.php @@ -29,17 +29,20 @@ use App\Notifications\NewComment; use App\Notifications\NewCommentTag; use App\Repositories\ChatRepository; +use App\Traits\CastLivewireProperties; use Illuminate\Support\Facades\Notification; use Livewire\Component; use voku\helper\AntiXSS; class Comment extends Component { + use CastLivewireProperties; + protected ChatRepository $chatRepository; public $comment; - public $anon = false; + public bool $anon = false; public ?User $user; @@ -73,6 +76,11 @@ final public function mount(): void $this->user = auth()->user(); } + final public function updating(string $field, mixed &$value): void + { + $this->castLivewireProperties($field, $value); + } + final public function taggedUsers(): array { preg_match_all('/@([\w\-]+)/', implode('', $this->editState), $matches); diff --git a/app/Http/Livewire/Comments.php b/app/Http/Livewire/Comments.php index 27b44a9475..439cb044d9 100644 --- a/app/Http/Livewire/Comments.php +++ b/app/Http/Livewire/Comments.php @@ -30,6 +30,7 @@ use App\Notifications\NewComment; use App\Notifications\NewCommentTag; use App\Repositories\ChatRepository; +use App\Traits\CastLivewireProperties; use Illuminate\Support\Facades\Notification; use Livewire\Component; use Livewire\WithPagination; @@ -37,6 +38,8 @@ class Comments extends Component { + use CastLivewireProperties; + use WithPagination; protected ChatRepository $chatRepository; @@ -45,7 +48,7 @@ class Comments extends Component public $model; - public $anon = false; + public bool $anon = false; public int $perPage = 10; @@ -71,6 +74,11 @@ final public function mount(): void $this->user = auth()->user(); } + final public function updating(string $field, mixed &$value): void + { + $this->castLivewireProperties($field, $value); + } + final public function taggedUsers(): array { preg_match_all('/@([\w\-]+)/', implode('', $this->newCommentState), $matches); @@ -196,6 +204,9 @@ final public function postComment(): void $this->gotoPage(1); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getCommentsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return $this->model diff --git a/app/Http/Livewire/CompanySearch.php b/app/Http/Livewire/CompanySearch.php index cc832ac153..4524eb7b78 100644 --- a/app/Http/Livewire/CompanySearch.php +++ b/app/Http/Livewire/CompanySearch.php @@ -21,7 +21,7 @@ class CompanySearch extends Component { use WithPagination; - public $search = ''; + public string $search = ''; final public function updatedPage(): void { @@ -33,6 +33,9 @@ final public function updatingSearch(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getCompaniesProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Company::withCount('tv', 'movie') diff --git a/app/Http/Livewire/FailedLoginSearch.php b/app/Http/Livewire/FailedLoginSearch.php index 61e898ec8d..c1714c9c37 100644 --- a/app/Http/Livewire/FailedLoginSearch.php +++ b/app/Http/Livewire/FailedLoginSearch.php @@ -14,6 +14,7 @@ namespace App\Http\Livewire; use App\Models\FailedLoginAttempt; +use App\Traits\LivewireSort; use Carbon\Carbon; use Illuminate\Support\Facades\DB; use Livewire\Component; @@ -21,6 +22,7 @@ class FailedLoginSearch extends Component { + use LivewireSort; use WithPagination; public string $username = ''; @@ -35,6 +37,9 @@ class FailedLoginSearch extends Component public string $sortDirection = 'desc'; + /** + * @var array + */ protected $queryString = [ 'username' => ['except' => ''], 'userId' => ['except' => ''], @@ -48,6 +53,9 @@ final public function updatedPage(): void $this->emit('paginationChanged'); } + /** + * @return \Illuminate\Database\Eloquent\Collection + */ final public function getFailedLoginsTop10IpProperty(): \Illuminate\Database\Eloquent\Collection { return FailedLoginAttempt::query() @@ -60,6 +68,9 @@ final public function getFailedLoginsTop10IpProperty(): \Illuminate\Database\Elo ->get(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getFailedLoginsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return FailedLoginAttempt::query() @@ -71,17 +82,6 @@ final public function getFailedLoginsProperty(): \Illuminate\Contracts\Paginatio ->paginate($this->perPage); } - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } - final public function render(): \Illuminate\Contracts\View\View|\Illuminate\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application { return view('livewire.failed-login-search', [ diff --git a/app/Http/Livewire/ForumCategoryTopicSearch.php b/app/Http/Livewire/ForumCategoryTopicSearch.php index f2298dae4a..3620c33bae 100644 --- a/app/Http/Livewire/ForumCategoryTopicSearch.php +++ b/app/Http/Livewire/ForumCategoryTopicSearch.php @@ -22,14 +22,17 @@ class ForumCategoryTopicSearch extends Component { use WithPagination; - public String $search = ''; - public String $sortField = 'last_reply_at'; - public String $sortDirection = 'desc'; - public String $label = ''; - public String $state = ''; - public String $subscribed = ''; + public string $search = ''; + public string $sortField = 'last_reply_at'; + public string $sortDirection = 'desc'; + public string $label = ''; + public string $state = ''; + public string $subscribed = ''; public Forum $category; + /** + * @var array + */ protected $queryString = [ 'search' => ['except' => ''], 'sortField' => ['except' => 'last_reply_at'], @@ -54,6 +57,9 @@ final public function updatingSearch(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getTopicsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Topic::query() diff --git a/app/Http/Livewire/ForumTopicSearch.php b/app/Http/Livewire/ForumTopicSearch.php index 44a1be86b0..c1ead9815c 100644 --- a/app/Http/Livewire/ForumTopicSearch.php +++ b/app/Http/Livewire/ForumTopicSearch.php @@ -23,15 +23,18 @@ class ForumTopicSearch extends Component { use WithPagination; - public String $search = ''; - public String $sortField = 'last_reply_at'; - public String $sortDirection = 'desc'; - public String $label = ''; - public String $state = ''; - public String $subscribed = ''; + public string $search = ''; + public string $sortField = 'last_reply_at'; + public string $sortDirection = 'desc'; + public string $label = ''; + public string $state = ''; + public string $subscribed = ''; public Forum $forum; public ?Subscription $subscription; + /** + * @var array + */ protected $queryString = [ 'search' => ['except' => ''], 'sortField' => ['except' => 'last_reply_at'], @@ -57,6 +60,9 @@ final public function updatingSearch(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getTopicsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Topic::query() diff --git a/app/Http/Livewire/GiftLogSearch.php b/app/Http/Livewire/GiftLogSearch.php index 8538fdf21e..85a90d84f0 100644 --- a/app/Http/Livewire/GiftLogSearch.php +++ b/app/Http/Livewire/GiftLogSearch.php @@ -15,6 +15,7 @@ use App\Models\BonTransactions; use App\Models\User; +use App\Traits\LivewireSort; use Livewire\Component; use Livewire\WithPagination; @@ -23,6 +24,7 @@ */ class GiftLogSearch extends Component { + use LivewireSort; use WithPagination; public string $sender = ''; @@ -37,6 +39,9 @@ class GiftLogSearch extends Component public int $perPage = 25; + /** + * @var array + */ protected $queryString = [ 'sender' => ['except' => ''], 'receiver' => ['except' => ''], @@ -49,6 +54,9 @@ final public function updatedPage(): void $this->emit('paginationChanged'); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getGiftsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return BonTransactions::with([ @@ -69,15 +77,4 @@ final public function render(): \Illuminate\Contracts\View\View|\Illuminate\Foun 'gifts' => $this->gifts, ]); } - - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } } diff --git a/app/Http/Livewire/HistorySearch.php b/app/Http/Livewire/HistorySearch.php index 5d8ed9fe2c..9591c42087 100644 --- a/app/Http/Livewire/HistorySearch.php +++ b/app/Http/Livewire/HistorySearch.php @@ -16,6 +16,7 @@ use App\Models\History; use App\Models\Torrent; use App\Models\User; +use App\Traits\LivewireSort; use Illuminate\Support\Facades\DB; use Livewire\Component; use Livewire\WithPagination; @@ -25,6 +26,7 @@ */ class HistorySearch extends Component { + use LivewireSort; use WithPagination; public int $perPage = 25; @@ -37,6 +39,9 @@ class HistorySearch extends Component public string $sortField = ''; public string $sortDirection = 'desc'; + /** + * @var array + */ protected $queryString = [ 'page' => ['except' => 1], 'perPage' => ['except' => 25], @@ -85,6 +90,9 @@ final public function updatingGroupBy(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getHistoriesProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return History::query() @@ -154,17 +162,6 @@ final public function getHistoriesProperty(): \Illuminate\Contracts\Pagination\L ->paginate($this->perPage); } - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } - final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { return view('livewire.history-search', [ diff --git a/app/Http/Livewire/InviteLogSearch.php b/app/Http/Livewire/InviteLogSearch.php index 8b51d6ec61..f23439b11f 100644 --- a/app/Http/Livewire/InviteLogSearch.php +++ b/app/Http/Livewire/InviteLogSearch.php @@ -15,12 +15,14 @@ use App\Models\Invite; use App\Models\User; +use App\Traits\LivewireSort; use Illuminate\Support\Facades\DB; use Livewire\Component; use Livewire\WithPagination; class InviteLogSearch extends Component { + use LivewireSort; use WithPagination; public string $sender = ''; @@ -43,6 +45,9 @@ class InviteLogSearch extends Component public int $perPage = 25; + /** + * @var array + */ protected $queryString = [ 'sender' => ['except' => ''], 'email' => ['except' => ''], @@ -78,6 +83,9 @@ final public function updatingGroupBy($value): void }; } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getInvitesProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Invite::withTrashed() @@ -137,15 +145,4 @@ final public function render(): \Illuminate\Contracts\View\View|\Illuminate\Foun 'invites' => $this->invites, ]); } - - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } } diff --git a/app/Http/Livewire/LaravelLogViewer.php b/app/Http/Livewire/LaravelLogViewer.php index f9a108a115..04f15c61f2 100644 --- a/app/Http/Livewire/LaravelLogViewer.php +++ b/app/Http/Livewire/LaravelLogViewer.php @@ -13,6 +13,7 @@ namespace App\Http\Livewire; +use App\Traits\CastLivewireProperties; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Support\Facades\File; use Livewire\Component; @@ -25,16 +26,26 @@ */ class LaravelLogViewer extends Component { + use CastLivewireProperties; use WithPagination; - public $logs = [0]; + /** + * @var int[]|string[] + */ + public array $logs = [0]; - public $page = 1; - - public $perPage = 5; + public int $perPage = 5; + /** + * @var array + */ protected $queryString = ['page']; + final public function updating(string $field, mixed &$value): void + { + $this->castLivewireProperties($field, $value); + } + final public function updatedPage(): void { $this->emit('paginationChanged'); diff --git a/app/Http/Livewire/MissingMediaSearch.php b/app/Http/Livewire/MissingMediaSearch.php index f0bf515a57..97c69f320f 100644 --- a/app/Http/Livewire/MissingMediaSearch.php +++ b/app/Http/Livewire/MissingMediaSearch.php @@ -4,11 +4,13 @@ use App\Models\Movie; use App\Models\Type; +use App\Traits\LivewireSort; use Livewire\Component; use Livewire\WithPagination; class MissingMediaSearch extends Component { + use LivewireSort; use WithPagination; public array $categories = []; @@ -19,6 +21,9 @@ class MissingMediaSearch extends Component public string $sortDirection = 'desc'; + /** + * @var array + */ protected $queryString = [ 'categories' => ['except' => []], 'sortField' => ['except' => 'created_at'], @@ -27,6 +32,9 @@ class MissingMediaSearch extends Component 'perPage' => ['except' => ''], ]; + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getMediasProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Movie::with(['torrents:tmdb,resolution_id,type_id' => ['resolution:id,position,name']]) @@ -35,21 +43,14 @@ final public function getMediasProperty(): \Illuminate\Contracts\Pagination\Leng ->paginate($this->perPage); } + /** + * @return \Illuminate\Database\Eloquent\Collection + */ final public function getTypesProperty(): \Illuminate\Database\Eloquent\Collection { return Type::select('id', 'position', 'name')->orderBy('position')->get(); } - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - $this->sortField = $field; - } - final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { return view('livewire.missing-media-search', ['medias' => $this->medias, 'types' => $this->types]); diff --git a/app/Http/Livewire/NetworkSearch.php b/app/Http/Livewire/NetworkSearch.php index 97eab9001b..ee637659a8 100644 --- a/app/Http/Livewire/NetworkSearch.php +++ b/app/Http/Livewire/NetworkSearch.php @@ -21,7 +21,7 @@ class NetworkSearch extends Component { use WithPagination; - public $search = ''; + public string $search = ''; final public function updatedPage(): void { @@ -33,6 +33,9 @@ final public function updatingSearch(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getNetworksProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Network::withCount('tv') diff --git a/app/Http/Livewire/NoteSearch.php b/app/Http/Livewire/NoteSearch.php index 73804e0c0f..d9788fc145 100644 --- a/app/Http/Livewire/NoteSearch.php +++ b/app/Http/Livewire/NoteSearch.php @@ -14,6 +14,9 @@ class NoteSearch extends Component public string $search = ''; + /** + * @var array + */ protected $queryString = [ 'search' => ['except' => ''], 'page' => ['except' => 1], @@ -30,6 +33,9 @@ final public function updatingSearch(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getNotesProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Note::query() diff --git a/app/Http/Livewire/NotificationSearch.php b/app/Http/Livewire/NotificationSearch.php index 2203b94133..6c15f79a9d 100644 --- a/app/Http/Livewire/NotificationSearch.php +++ b/app/Http/Livewire/NotificationSearch.php @@ -14,11 +14,13 @@ namespace App\Http\Livewire; use App\Models\User; +use App\Traits\LivewireSort; use Livewire\Component; use Livewire\WithPagination; class NotificationSearch extends Component { + use LivewireSort; use WithPagination; public bool $bon_gifts = false; @@ -70,6 +72,9 @@ final public function updatedPage(): void $this->emit('paginationChanged'); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator<\Illuminate\Notifications\DatabaseNotification> + */ final public function getNotificationsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return auth()->user()->notifications() @@ -138,17 +143,6 @@ final public function getNotificationsProperty(): \Illuminate\Contracts\Paginati ->paginate($this->perPage); } - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } - final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { return view('livewire.notification-search', [ diff --git a/app/Http/Livewire/PasskeySearch.php b/app/Http/Livewire/PasskeySearch.php index ad59cf2c8b..41b94556d9 100644 --- a/app/Http/Livewire/PasskeySearch.php +++ b/app/Http/Livewire/PasskeySearch.php @@ -15,6 +15,7 @@ use App\Models\Passkey; use App\Models\User; +use App\Traits\LivewireSort; use Livewire\Component; use Livewire\WithPagination; @@ -23,6 +24,7 @@ */ class PasskeySearch extends Component { + use LivewireSort; use WithPagination; public string $username = ''; @@ -36,7 +38,7 @@ class PasskeySearch extends Component public int $perPage = 25; /** - * @var array + * @var array */ protected $queryString = [ 'username' => ['except' => ''], @@ -70,15 +72,4 @@ final public function render(): \Illuminate\Contracts\View\View|\Illuminate\Foun 'passkeys' => $this->passkeys, ]); } - - final public function sortBy(string $field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } } diff --git a/app/Http/Livewire/PeerSearch.php b/app/Http/Livewire/PeerSearch.php index c82cc484a4..6e956346b8 100644 --- a/app/Http/Livewire/PeerSearch.php +++ b/app/Http/Livewire/PeerSearch.php @@ -15,12 +15,14 @@ use App\Models\Peer; use App\Models\Torrent; +use App\Traits\LivewireSort; use Illuminate\Support\Facades\DB; use Livewire\Component; use Livewire\WithPagination; class PeerSearch extends Component { + use LivewireSort; use WithPagination; public bool $duplicateIpsOnly = false; @@ -36,6 +38,9 @@ class PeerSearch extends Component public string $sortField = 'created_at'; public string $sortDirection = 'desc'; + /** + * @var array + */ protected $queryString = [ 'page' => ['except' => 1], 'duplicateIpsOnly' => ['except' => false], @@ -84,6 +89,9 @@ final public function updatingGroupBy(): void } } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getPeersProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Peer::query() @@ -211,17 +219,6 @@ final public function getPeersProperty(): \Illuminate\Contracts\Pagination\Lengt ->paginate($this->perPage); } - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'desc'; - } - - $this->sortField = $field; - } - final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { return view('livewire.peer-search', [ diff --git a/app/Http/Livewire/PersonCredit.php b/app/Http/Livewire/PersonCredit.php index f77cf35ea7..270e0d62a2 100644 --- a/app/Http/Livewire/PersonCredit.php +++ b/app/Http/Livewire/PersonCredit.php @@ -26,6 +26,9 @@ class PersonCredit extends Component public ?int $occupationId = null; + /** + * @var array + */ public $queryString = [ 'occupationId', ]; @@ -47,9 +50,9 @@ final public function mount(): void }; } - final public function getPersonalFreeleechProperty() + final public function getPersonalFreeleechProperty(): bool { - return cache()->get('personal_freeleech:'.auth()->user()->id); + return cache()->get('personal_freeleech:'.auth()->user()->id) ?? false; } /* @@ -110,6 +113,9 @@ public function getActedCountProperty(): int return $this->person->actedMovies()->count() + $this->person->actedTv()->count(); } + /** + * @return \Illuminate\Support\Collection + */ final public function getMediasProperty(): \Illuminate\Support\Collection { if ($this->occupationId === null) { diff --git a/app/Http/Livewire/PersonSearch.php b/app/Http/Livewire/PersonSearch.php index 8f0f571edb..0a8c1bc6b1 100644 --- a/app/Http/Livewire/PersonSearch.php +++ b/app/Http/Livewire/PersonSearch.php @@ -21,7 +21,7 @@ class PersonSearch extends Component { use WithPagination; - public $search = ''; + public string $search = ''; final public function updatedPage(): void { @@ -33,6 +33,9 @@ final public function updatingSearch(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getPersonsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Person::select(['id', 'still', 'name']) diff --git a/app/Http/Livewire/PostSearch.php b/app/Http/Livewire/PostSearch.php index 3223d2cb14..80424c4708 100644 --- a/app/Http/Livewire/PostSearch.php +++ b/app/Http/Livewire/PostSearch.php @@ -24,6 +24,9 @@ class PostSearch extends Component public String $search = ''; + /** + * @var array + */ protected $queryString = [ 'search' => ['except' => ''], ]; @@ -37,6 +40,9 @@ final public function updatingSearch(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getPostsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Post::query() diff --git a/app/Http/Livewire/RsskeySearch.php b/app/Http/Livewire/RsskeySearch.php index bc8ff6e9ad..8ecd14d408 100644 --- a/app/Http/Livewire/RsskeySearch.php +++ b/app/Http/Livewire/RsskeySearch.php @@ -15,6 +15,7 @@ use App\Models\Rsskey; use App\Models\User; +use App\Traits\LivewireSort; use Livewire\Component; use Livewire\WithPagination; @@ -23,6 +24,7 @@ */ class RsskeySearch extends Component { + use LivewireSort; use WithPagination; public string $username = ''; @@ -36,7 +38,7 @@ class RsskeySearch extends Component public int $perPage = 25; /** - * @var array + * @var array */ protected $queryString = [ 'username' => ['except' => ''], @@ -70,15 +72,4 @@ final public function render(): \Illuminate\Contracts\View\View|\Illuminate\Foun 'rsskeys' => $this->rsskeys, ]); } - - final public function sortBy(string $field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } } diff --git a/app/Http/Livewire/SimilarTorrent.php b/app/Http/Livewire/SimilarTorrent.php index ddcccc04df..cf39fddb33 100644 --- a/app/Http/Livewire/SimilarTorrent.php +++ b/app/Http/Livewire/SimilarTorrent.php @@ -21,22 +21,30 @@ use App\Models\TorrentRequest; use App\Models\Tv; use App\Services\Unit3dAnnounce; +use App\Traits\CastLivewireProperties; +use App\Traits\LivewireSort; use Livewire\Component; use MarcReichel\IGDBLaravel\Models\Game; class SimilarTorrent extends Component { + use CastLivewireProperties; + use LivewireSort; + public Category $category; public Movie|Tv|Game $work; - public $tmdbId; + public int $tmdbId; - public $igdbId; + public int $igdbId; - public $reason; + public string $reason; - public $checked = []; + /** + * @var string[] + */ + public array $checked = []; public bool $selectPage = false; @@ -48,6 +56,11 @@ class SimilarTorrent extends Component protected $listeners = ['destroy' => 'deleteRecords']; + final public function updating(string $field, mixed &$value): void + { + $this->castLivewireProperties($field, $value); + } + final public function updatedSelectPage($value): void { $this->checked = $value ? $this->torrents->pluck('id')->map(fn ($item) => (string) $item)->toArray() : []; @@ -69,6 +82,9 @@ final public function isChecked($torrentId): bool return \in_array($torrentId, $this->checked); } + /** + * @return \Illuminate\Support\Collection + */ final public function getTorrentsProperty(): \Illuminate\Support\Collection { $user = auth()->user(); @@ -113,7 +129,10 @@ final public function getTorrentsProperty(): \Illuminate\Support\Collection ->get(); } - final public function getTorrentRequestsProperty(): array|\Illuminate\Database\Eloquent\Collection + /** + * @return \Illuminate\Database\Eloquent\Collection + */ + final public function getTorrentRequestsProperty(): \Illuminate\Database\Eloquent\Collection { return TorrentRequest::with(['user:id,username,group_id', 'user.group', 'category', 'type', 'resolution']) ->withCount(['comments']) @@ -123,17 +142,6 @@ final public function getTorrentRequestsProperty(): array|\Illuminate\Database\E ->get(); } - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } - final public function alertConfirm(): void { if (!auth()->user()->group->is_modo) { @@ -238,9 +246,9 @@ final public function deleteRecords(): void ]); } - final public function getPersonalFreeleechProperty() + final public function getPersonalFreeleechProperty(): bool { - return cache()->get('personal_freeleech:'.auth()->id()); + return cache()->get('personal_freeleech:'.auth()->id()) ?? false; } final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application diff --git a/app/Http/Livewire/SubscribedForum.php b/app/Http/Livewire/SubscribedForum.php index 18be96cc28..d30e845c9f 100644 --- a/app/Http/Livewire/SubscribedForum.php +++ b/app/Http/Livewire/SubscribedForum.php @@ -21,6 +21,9 @@ class SubscribedForum extends Component { use WithPagination; + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getForumsProperty() { return Forum::query() diff --git a/app/Http/Livewire/SubscribedTopic.php b/app/Http/Livewire/SubscribedTopic.php index e4d7e371fe..8dcf2667a0 100644 --- a/app/Http/Livewire/SubscribedTopic.php +++ b/app/Http/Livewire/SubscribedTopic.php @@ -21,6 +21,9 @@ class SubscribedTopic extends Component { use WithPagination; + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getTopicsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Topic::query() diff --git a/app/Http/Livewire/SubtitleSearch.php b/app/Http/Livewire/SubtitleSearch.php index 182a2390ba..11b72e4d05 100644 --- a/app/Http/Livewire/SubtitleSearch.php +++ b/app/Http/Livewire/SubtitleSearch.php @@ -16,17 +16,22 @@ use App\Models\Subtitle; use App\Models\Torrent; use App\Models\User; +use App\Traits\LivewireSort; use Livewire\Component; use Livewire\WithPagination; class SubtitleSearch extends Component { + use LivewireSort; use WithPagination; public int $perPage = 25; public string $search = ''; + /** + * @var string[] + */ public array $categories = []; public string $language = ''; @@ -47,6 +52,9 @@ final public function updatingSearch(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getSubtitlesProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Subtitle::with(['user.group', 'torrent.category', 'language']) @@ -71,17 +79,6 @@ final public function getSubtitlesProperty(): \Illuminate\Contracts\Pagination\L ->paginate($this->perPage); } - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } - final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { return view('livewire.subtitle-search', [ diff --git a/app/Http/Livewire/ThankButton.php b/app/Http/Livewire/ThankButton.php index 0ddf634d6f..78c803a298 100644 --- a/app/Http/Livewire/ThankButton.php +++ b/app/Http/Livewire/ThankButton.php @@ -21,11 +21,11 @@ class ThankButton extends Component { - public $torrent; + public ?Torrent $torrent = null; public ?User $user = null; - final public function mount($torrent): void + final public function mount(int $torrent): void { $this->user = auth()->user(); $this->torrent = Torrent::withoutGlobalScope(ApprovedScope::class)->findOrFail($torrent); diff --git a/app/Http/Livewire/TicketSearch.php b/app/Http/Livewire/TicketSearch.php index 8786911bcd..c0ef5b6c20 100644 --- a/app/Http/Livewire/TicketSearch.php +++ b/app/Http/Livewire/TicketSearch.php @@ -15,6 +15,7 @@ use App\Models\Ticket; use App\Models\User; +use App\Traits\LivewireSort; use Livewire\Component; use Livewire\WithPagination; @@ -23,6 +24,7 @@ */ class TicketSearch extends Component { + use LivewireSort; use WithPagination; public ?User $user = null; @@ -37,6 +39,9 @@ class TicketSearch extends Component public string $sortDirection = 'desc'; + /** + * @var array + */ protected $queryString = [ 'search' => ['except' => ''], 'tab' => ['except' => 'open'], @@ -62,6 +67,9 @@ final public function updatingTab(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getTicketsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Ticket::query() @@ -77,17 +85,6 @@ final public function getTicketsProperty(): \Illuminate\Contracts\Pagination\Len ->paginate($this->perPage); } - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } - final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { return view('livewire.ticket-search', [ diff --git a/app/Http/Livewire/Top10.php b/app/Http/Livewire/Top10.php index f8235faf75..e53b77485a 100644 --- a/app/Http/Livewire/Top10.php +++ b/app/Http/Livewire/Top10.php @@ -30,7 +30,7 @@ class Top10 extends Component public string $interval = 'day'; /** - * @var array + * @var array */ protected $queryString = [ 'metaType' => ['except' => 'movie_meta'], diff --git a/app/Http/Livewire/TopicPostSearch.php b/app/Http/Livewire/TopicPostSearch.php index aa340ef379..c0b2789cc0 100644 --- a/app/Http/Livewire/TopicPostSearch.php +++ b/app/Http/Livewire/TopicPostSearch.php @@ -22,10 +22,13 @@ class TopicPostSearch extends Component { use WithPagination; - public String $search = ''; + public string $search = ''; public Topic $topic; + /** + * @var array + */ protected $queryString = [ 'search' => ['except' => ''], ]; @@ -45,6 +48,9 @@ final public function updatingSearch(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getPostsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Post::query() diff --git a/app/Http/Livewire/TopicSearch.php b/app/Http/Livewire/TopicSearch.php index e5d489fa4c..3aa70bda16 100644 --- a/app/Http/Livewire/TopicSearch.php +++ b/app/Http/Livewire/TopicSearch.php @@ -22,14 +22,17 @@ class TopicSearch extends Component { use WithPagination; - public String $search = ''; - public String $sortField = 'last_reply_at'; - public String $sortDirection = 'desc'; - public String $label = ''; - public String $state = ''; - public String $subscribed = ''; + public string $search = ''; + public string $sortField = 'last_reply_at'; + public string $sortDirection = 'desc'; + public string $label = ''; + public string $state = ''; + public string $subscribed = ''; public String $forumId = ''; + /** + * @var array + */ protected $queryString = [ 'search' => ['except' => ''], 'sortField' => ['except' => 'last_reply_at'], @@ -50,7 +53,10 @@ final public function updatingSearch(): void $this->resetPage(); } - final public function getForumCategoriesProperty() + /** + * @return \Illuminate\Support\Collection + */ + final public function getForumCategoriesProperty(): \Illuminate\Support\Collection { return Forum::query() ->with(['forums' => fn ($query) => $query @@ -62,6 +68,9 @@ final public function getForumCategoriesProperty() ->get(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getTopicsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Topic::query() diff --git a/app/Http/Livewire/TorrentRequestSearch.php b/app/Http/Livewire/TorrentRequestSearch.php index f55f2756f0..4d65856f68 100644 --- a/app/Http/Livewire/TorrentRequestSearch.php +++ b/app/Http/Livewire/TorrentRequestSearch.php @@ -16,49 +16,65 @@ use App\Models\TorrentRequest; use App\Models\TorrentRequestBounty; use App\Models\TorrentRequestClaim; +use App\Traits\CastLivewireProperties; +use App\Traits\LivewireSort; use Illuminate\Support\Facades\DB; use Livewire\Component; use Livewire\WithPagination; class TorrentRequestSearch extends Component { + use CastLivewireProperties; + use LivewireSort; use WithPagination; public string $name = ''; public string $requestor = ''; + /** + * @var string[] + */ public array $categories = []; + /** + * @var string[] + */ public array $types = []; + /** + * @var string[] + */ public array $resolutions = []; + /** + * @var string[] + */ public array $genres = []; - public string $tmdbId = ''; + public ?int $tmdbId = null; public string $imdbId = ''; - public string $tvdbId = ''; + public ?int $tvdbId = null; - public string $malId = ''; + public ?int $malId = null; - public $unfilled; + public bool $unfilled = false; - public $claimed; + public bool $claimed = false; - public $pending; + public bool $pending = false; - public $filled; + public bool $filled = false; - public $myRequests; + public bool $myRequests = false; - public $myClaims; + public bool $myClaims = false; - public $myVoted; + public bool $myVoted = false; - public $myFilled; + public bool $myFilled = false; public int $perPage = 25; @@ -68,6 +84,9 @@ class TorrentRequestSearch extends Component public bool $showFilters = false; + /** + * @var array + */ protected $queryString = [ 'name' => ['except' => ''], 'requestor' => ['except' => ''], @@ -92,6 +111,11 @@ class TorrentRequestSearch extends Component 'page' => ['except' => 1], ]; + final public function updating(string $field, mixed &$value): void + { + $this->castLivewireProperties($field, $value); + } + final public function updatedPage(): void { $this->emit('paginationChanged'); @@ -120,6 +144,9 @@ final public function getTorrentRequestBountyStatProperty(): ?object ->first(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getTorrentRequestsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { $user = auth()->user(); @@ -137,10 +164,10 @@ final public function getTorrentRequestsProperty(): \Illuminate\Contracts\Pagina ->when($this->categories !== [], fn ($query) => $query->ofCategory($this->categories)) ->when($this->types !== [], fn ($query) => $query->ofType($this->types)) ->when($this->resolutions !== [], fn ($query) => $query->ofResolution($this->resolutions)) - ->when($this->tmdbId !== '', fn ($query) => $query->ofTmdb((int) $this->tmdbId)) + ->when($this->tmdbId !== null, fn ($query) => $query->ofTmdb($this->tmdbId)) ->when($this->imdbId !== '', fn ($query) => $query->ofImdb((int) (preg_match('/tt0*(?=(\d{7,}))/', $this->imdbId, $matches) ? $matches[1] : $this->imdbId))) - ->when($this->tvdbId !== '', fn ($query) => $query->ofTvdb((int) $this->tvdbId)) - ->when($this->malId !== '', fn ($query) => $query->ofMal((int) $this->malId)) + ->when($this->tvdbId !== null, fn ($query) => $query->ofTvdb((int) $this->tvdbId)) + ->when($this->malId !== null, fn ($query) => $query->ofMal((int) $this->malId)) ->when($this->unfilled || $this->claimed || $this->pending || $this->filled, function ($query): void { $query->where(function ($query): void { $query->where(function ($query): void { @@ -183,17 +210,6 @@ final public function getTorrentRequestsProperty(): \Illuminate\Contracts\Pagina ->paginate($this->perPage); } - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } - final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { return view('livewire.torrent-request-search', [ diff --git a/app/Http/Livewire/TorrentSearch.php b/app/Http/Livewire/TorrentSearch.php index 466fa3599f..3d03842d9e 100644 --- a/app/Http/Livewire/TorrentSearch.php +++ b/app/Http/Livewire/TorrentSearch.php @@ -18,6 +18,8 @@ use App\Models\Torrent; use App\Models\Tv; use App\Models\User; +use App\Traits\CastLivewireProperties; +use App\Traits\LivewireSort; use Illuminate\Database\Eloquent\Builder; use Livewire\Component; use Livewire\WithPagination; @@ -25,6 +27,8 @@ class TorrentSearch extends Component { + use CastLivewireProperties; + use LivewireSort; use WithPagination; public string $name = ''; @@ -37,9 +41,9 @@ class TorrentSearch extends Component public string $keywords = ''; - public string $startYear = ''; + public ?int $startYear = null; - public string $endYear = ''; + public ?int $endYear = null; public ?int $minSize = null; @@ -49,41 +53,62 @@ class TorrentSearch extends Component public int $maxSizeMultiplier = 1; + /** + * @var string[] + */ public array $categories = []; + /** + * @var string[] + */ public array $types = []; + /** + * @var string[] + */ public array $resolutions = []; + /** + * @var string[] + */ public array $genres = []; + /** + * @var string[] + */ public array $regions = []; + /** + * @var string[] + */ public array $distributors = []; public string $adult = 'any'; - public string $tmdbId = ''; + public ?int $tmdbId = null; public string $imdbId = ''; - public string $tvdbId = ''; + public ?int $tvdbId = null; - public string $malId = ''; + public ?int $malId = null; - public string $playlistId = ''; + public ?int $playlistId = null; - public string $collectionId = ''; + public ?int $collectionId = null; - public string $networkId = ''; + public ?int $networkId = null; - public string $companyId = ''; + public ?int $companyId = null; /** * @var string[] */ public array $primaryLanguages = []; + /** + * @var string[] + */ public array $free = []; public bool $doubleup = false; @@ -132,6 +157,9 @@ class TorrentSearch extends Component public string $view = 'list'; + /** + * @var array + */ protected $queryString = [ 'name' => ['except' => ''], 'description' => ['except' => ''], @@ -183,6 +211,11 @@ class TorrentSearch extends Component 'view' => ['except' => 'list'], ]; + final public function updating(string $field, mixed &$value): void + { + $this->castLivewireProperties($field, $value); + } + final public function updatedPage(): void { $this->emit('paginationChanged'); @@ -198,11 +231,14 @@ final public function updatedView(): void $this->perPage = \in_array($this->view, ['card', 'poster']) ? 24 : 25; } - final public function getPersonalFreeleechProperty() + final public function getPersonalFreeleechProperty(): bool { - return cache()->get('personal_freeleech:'.auth()->id()); + return cache()->get('personal_freeleech:'.auth()->id()) ?? false; } + /** + * @return Closure(Builder): Builder + */ final public function filters(): Closure { $user = auth()->user(); @@ -219,24 +255,24 @@ final public function filters(): Closure ->when($this->mediainfo !== '', fn ($query) => $query->ofMediainfo($this->mediainfo, $isRegex($this->mediainfo))) ->when($this->uploader !== '', fn ($query) => $query->ofUploader($this->uploader)) ->when($this->keywords !== '', fn ($query) => $query->ofKeyword(array_map('trim', explode(',', $this->keywords)))) - ->when($this->startYear !== '', fn ($query) => $query->releasedAfterOrIn((int) $this->startYear)) - ->when($this->endYear !== '', fn ($query) => $query->releasedBeforeOrIn((int) $this->endYear)) - ->when($this->minSize !== null, fn ($query) => $query->ofSizeGreaterOrEqualto((int) $this->minSize * $this->minSizeMultiplier)) - ->when($this->maxSize !== null, fn ($query) => $query->ofSizeLesserOrEqualTo((int) $this->maxSize * $this->maxSizeMultiplier)) + ->when($this->startYear !== null, fn ($query) => $query->releasedAfterOrIn($this->startYear)) + ->when($this->endYear !== null, fn ($query) => $query->releasedBeforeOrIn($this->endYear)) + ->when($this->minSize !== null, fn ($query) => $query->ofSizeGreaterOrEqualto($this->minSize * $this->minSizeMultiplier)) + ->when($this->maxSize !== null, fn ($query) => $query->ofSizeLesserOrEqualTo($this->maxSize * $this->maxSizeMultiplier)) ->when($this->categories !== [], fn ($query) => $query->ofCategory($this->categories)) ->when($this->types !== [], fn ($query) => $query->ofType($this->types)) ->when($this->resolutions !== [], fn ($query) => $query->ofResolution($this->resolutions)) ->when($this->genres !== [], fn ($query) => $query->ofGenre($this->genres)) ->when($this->regions !== [], fn ($query) => $query->ofRegion($this->regions)) ->when($this->distributors !== [], fn ($query) => $query->ofDistributor($this->distributors)) - ->when($this->tmdbId !== '', fn ($query) => $query->ofTmdb((int) $this->tmdbId)) + ->when($this->tmdbId !== null, fn ($query) => $query->ofTmdb($this->tmdbId)) ->when($this->imdbId !== '', fn ($query) => $query->ofImdb((int) (preg_match('/tt0*(?=(\d{7,}))/', $this->imdbId, $matches) ? $matches[1] : $this->imdbId))) - ->when($this->tvdbId !== '', fn ($query) => $query->ofTvdb((int) $this->tvdbId)) - ->when($this->malId !== '', fn ($query) => $query->ofMal((int) $this->malId)) - ->when($this->playlistId !== '', fn ($query) => $query->ofPlaylist((int) $this->playlistId)) - ->when($this->collectionId !== '', fn ($query) => $query->ofCollection((int) $this->collectionId)) - ->when($this->companyId !== '', fn ($query) => $query->ofCompany((int) $this->companyId)) - ->when($this->networkId !== '', fn ($query) => $query->ofNetwork((int) $this->networkId)) + ->when($this->tvdbId !== null, fn ($query) => $query->ofTvdb($this->tvdbId)) + ->when($this->malId !== null, fn ($query) => $query->ofMal($this->malId)) + ->when($this->playlistId !== null, fn ($query) => $query->ofPlaylist($this->playlistId)) + ->when($this->collectionId !== null, fn ($query) => $query->ofCollection($this->collectionId)) + ->when($this->companyId !== null, fn ($query) => $query->ofCompany($this->companyId)) + ->when($this->networkId !== null, fn ($query) => $query->ofNetwork($this->networkId)) ->when($this->primaryLanguages !== [], fn ($query) => $query->ofPrimaryLanguage($this->primaryLanguages)) ->when($this->free !== [], fn ($query) => $query->ofFreeleech($this->free)) ->when($this->adult === 'include', fn ($query) => $query->ofAdult(true)) @@ -262,6 +298,9 @@ final public function filters(): Closure ->when($this->incomplete, fn ($query) => $query->uncompletedBy($user)); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getTorrentsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { $user = auth()->user(); @@ -342,6 +381,9 @@ final public function getTorrentsProperty(): \Illuminate\Contracts\Pagination\Le return $torrents; } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getGroupedTorrentsProperty() { $user = auth()->user(); @@ -583,6 +625,9 @@ function ($tv) { return $medias; } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getGroupedPostersProperty() { // Whitelist which columns are allowed to be ordered by @@ -632,17 +677,6 @@ final public function getGroupedPostersProperty() return $groups; } - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } - final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { return view('livewire.torrent-search', [ diff --git a/app/Http/Livewire/TvSearch.php b/app/Http/Livewire/TvSearch.php index d27ad2a2ff..d10666b55f 100644 --- a/app/Http/Livewire/TvSearch.php +++ b/app/Http/Livewire/TvSearch.php @@ -21,7 +21,7 @@ class TvSearch extends Component { use WithPagination; - public $search; + public string $search; final public function updatedPage(): void { @@ -33,6 +33,9 @@ final public function updatingSearch(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getShowsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Tv::with(['networks', 'genres']) diff --git a/app/Http/Livewire/UserActive.php b/app/Http/Livewire/UserActive.php index d0ae98a993..dc1ea88e81 100644 --- a/app/Http/Livewire/UserActive.php +++ b/app/Http/Livewire/UserActive.php @@ -15,6 +15,7 @@ use App\Models\Peer; use App\Models\User; +use App\Traits\LivewireSort; use Livewire\Component; use Livewire\WithPagination; @@ -23,6 +24,7 @@ */ class UserActive extends Component { + use LivewireSort; use WithPagination; public ?User $user = null; @@ -45,8 +47,11 @@ class UserActive extends Component public string $sortDirection = 'desc'; - public $showMorePrecision = false; + public bool $showMorePrecision = false; + /** + * @var array + */ protected $queryString = [ 'perPage' => ['except' => 50], 'name' => ['except' => ''], @@ -75,6 +80,9 @@ final public function updatingSearch(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getActivesProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Peer::query() @@ -123,15 +131,4 @@ final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\C 'actives' => $this->actives, ]); } - - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } } diff --git a/app/Http/Livewire/UserNotes.php b/app/Http/Livewire/UserNotes.php index f75e57e647..7e61201708 100644 --- a/app/Http/Livewire/UserNotes.php +++ b/app/Http/Livewire/UserNotes.php @@ -39,6 +39,9 @@ class UserNotes extends Component ], ]; + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getNotesProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Note::query() diff --git a/app/Http/Livewire/UserResurrections.php b/app/Http/Livewire/UserResurrections.php index 064cb7b9dc..a01df8d5d0 100644 --- a/app/Http/Livewire/UserResurrections.php +++ b/app/Http/Livewire/UserResurrections.php @@ -15,11 +15,13 @@ use App\Models\Resurrection; use App\Models\User; +use App\Traits\LivewireSort; use Livewire\Component; use Livewire\WithPagination; class UserResurrections extends Component { + use LivewireSort; use WithPagination; public ?User $user = null; @@ -34,6 +36,9 @@ class UserResurrections extends Component public string $sortDirection = 'desc'; + /** + * @var array + */ protected $queryString = [ 'perPage' => ['except' => ''], 'name' => ['except' => ''], @@ -57,6 +62,9 @@ final public function updatingSearch(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getResurrectionsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Resurrection::query() @@ -87,15 +95,4 @@ final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\C 'resurrections' => $this->resurrections, ]); } - - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } } diff --git a/app/Http/Livewire/UserSearch.php b/app/Http/Livewire/UserSearch.php index aa755c097e..adf7a37491 100644 --- a/app/Http/Livewire/UserSearch.php +++ b/app/Http/Livewire/UserSearch.php @@ -14,11 +14,13 @@ namespace App\Http\Livewire; use App\Models\User; +use App\Traits\LivewireSort; use Livewire\Component; use Livewire\WithPagination; class UserSearch extends Component { + use LivewireSort; use WithPagination; public bool $show = false; @@ -31,6 +33,9 @@ class UserSearch extends Component public string $sortDirection = 'desc'; + /** + * @var array + */ protected $queryString = [ 'search' => ['except' => ''], 'show' => ['except' => false], @@ -60,6 +65,9 @@ final public function toggleProperties($property): void } } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getUsersProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return User::query() @@ -78,17 +86,6 @@ final public function getUsersProperty(): \Illuminate\Contracts\Pagination\Lengt ->paginate($this->perPage); } - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } - final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { return view('livewire.user-search', [ diff --git a/app/Http/Livewire/UserTorrents.php b/app/Http/Livewire/UserTorrents.php index 51dc502455..75e61dafa6 100644 --- a/app/Http/Livewire/UserTorrents.php +++ b/app/Http/Livewire/UserTorrents.php @@ -15,11 +15,13 @@ use App\Models\History; use App\Models\User; +use App\Traits\LivewireSort; use Livewire\Component; use Livewire\WithPagination; class UserTorrents extends Component { + use LivewireSort; use WithPagination; public ?User $user = null; @@ -44,14 +46,20 @@ class UserTorrents extends Component public string $downloaded = 'any'; + /** + * @var string[] + */ public array $status = []; public string $sortField = 'created_at'; public string $sortDirection = 'desc'; - public $showMorePrecision = false; + public bool $showMorePrecision = false; + /** + * @var array + */ protected $queryString = [ 'perPage' => ['except' => ''], 'name' => ['except' => ''], @@ -84,6 +92,9 @@ final public function updatingSearch(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getHistoryProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return History::query() @@ -169,15 +180,4 @@ final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\C 'histories' => $this->history, ]); } - - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } } diff --git a/app/Http/Livewire/UserUploads.php b/app/Http/Livewire/UserUploads.php index 85084cb17b..78a5fa06a8 100644 --- a/app/Http/Livewire/UserUploads.php +++ b/app/Http/Livewire/UserUploads.php @@ -16,11 +16,13 @@ use App\Models\Scopes\ApprovedScope; use App\Models\Torrent; use App\Models\User; +use App\Traits\LivewireSort; use Livewire\Component; use Livewire\WithPagination; class UserUploads extends Component { + use LivewireSort; use WithPagination; public ?User $user = null; @@ -31,14 +33,20 @@ class UserUploads extends Component public string $personalRelease = 'any'; + /** + * @var string[] + */ public array $status = []; public string $sortField = 'created_at'; public string $sortDirection = 'desc'; - public $showMorePrecision = false; + public bool $showMorePrecision = false; + /** + * @var array + */ protected $queryString = [ 'perPage' => ['except' => ''], 'name' => ['except' => ''], @@ -63,6 +71,9 @@ final public function updatingSearch(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getUploadsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Torrent::query() @@ -89,15 +100,4 @@ final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\C 'uploads' => $this->uploads, ]); } - - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } } diff --git a/app/Http/Livewire/UserWarnings.php b/app/Http/Livewire/UserWarnings.php index ca90c6a3d3..3dd348ab57 100644 --- a/app/Http/Livewire/UserWarnings.php +++ b/app/Http/Livewire/UserWarnings.php @@ -16,6 +16,7 @@ use App\Models\PrivateMessage; use App\Models\User; use App\Models\Warning; +use App\Traits\LivewireSort; use Illuminate\Support\Carbon; use Livewire\Component; use Livewire\WithPagination; @@ -28,6 +29,8 @@ */ class UserWarnings extends Component { + use LivewireSort; + use LivewireSort; use WithPagination; public User $user; @@ -42,6 +45,9 @@ class UserWarnings extends Component public string $sortDirection = 'desc'; + /** + * @var array + */ protected $queryString = [ 'warningTab' => ['except' => 'automated'], ]; @@ -54,6 +60,9 @@ class UserWarnings extends Component ], ]; + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getWarningsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return $this->user @@ -251,17 +260,6 @@ final public function restore(int $id): void $this->dispatchBrowserEvent('success', ['type' => 'success', 'message' => 'Warning Was Successfully Restored']); } - final public function sortBy(string $field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } - final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { return view('livewire.user-warnings', [ diff --git a/app/Http/Livewire/WarningLogSearch.php b/app/Http/Livewire/WarningLogSearch.php index 48649cb933..4a64d163fc 100644 --- a/app/Http/Livewire/WarningLogSearch.php +++ b/app/Http/Livewire/WarningLogSearch.php @@ -16,11 +16,13 @@ use App\Models\Torrent; use App\Models\User; use App\Models\Warning; +use App\Traits\LivewireSort; use Livewire\Component; use Livewire\WithPagination; class WarningLogSearch extends Component { + use LivewireSort; use WithPagination; public string $sender = ''; @@ -39,6 +41,9 @@ class WarningLogSearch extends Component public string $sortDirection = 'desc'; + /** + * @var array + */ protected $queryString = [ 'sender' => ['except' => ''], 'receiver' => ['except' => ''], @@ -61,6 +66,9 @@ final public function toggleProperties($property): void } } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator + */ final public function getWarningsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Warning::query() @@ -74,17 +82,6 @@ final public function getWarningsProperty(): \Illuminate\Contracts\Pagination\Le ->paginate($this->perPage); } - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } - final public function render(): \Illuminate\Contracts\View\View|\Illuminate\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application { return view('livewire.warning-log-search', [ diff --git a/app/Http/Livewire/WatchlistSearch.php b/app/Http/Livewire/WatchlistSearch.php index 5cabc9a5c6..86b7f888e7 100644 --- a/app/Http/Livewire/WatchlistSearch.php +++ b/app/Http/Livewire/WatchlistSearch.php @@ -14,11 +14,13 @@ namespace App\Http\Livewire; use App\Models\Watchlist; +use App\Traits\LivewireSort; use Livewire\Component; use Livewire\WithPagination; class WatchlistSearch extends Component { + use LivewireSort; use WithPagination; public ?\Illuminate\Contracts\Auth\Authenticatable $user = null; @@ -46,6 +48,9 @@ final public function updatingSearch(): void $this->resetPage(); } + /** + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator<\App\Models\User> + */ final public function getUsersProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator { return Watchlist::query() @@ -55,17 +60,6 @@ final public function getUsersProperty(): \Illuminate\Contracts\Pagination\Lengt ->paginate($this->perPage); } - final public function sortBy($field): void - { - if ($this->sortField === $field) { - $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; - } else { - $this->sortDirection = 'asc'; - } - - $this->sortField = $field; - } - final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { return view('livewire.watchlist-search', [ diff --git a/app/Traits/CastLivewireProperties.php b/app/Traits/CastLivewireProperties.php new file mode 100644 index 0000000000..b808565d7f --- /dev/null +++ b/app/Traits/CastLivewireProperties.php @@ -0,0 +1,102 @@ + + * @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0 + */ + +namespace App\Traits; + +use ReflectionClass; +use ReflectionNamedType; +use Closure; + +use function theodorejb\polycast\safe_float; +use function theodorejb\polycast\safe_int; +use function theodorejb\polycast\safe_string; + +trait CastLivewireProperties +{ + /** + * Cast incoming livewire property updates from string form to the type of + * the property if the type is either int, float, or bool. If the type of + * the property is ?int, ?float, or ?bool and the incoming property update + * is an empty string, then set it to null. + * + * TODO: Livewire will automatically call lifecycle hooks in traits if the + * function is suffixed by the trait name, however, in livewire v2, this + * doesn't work when passing the value by reference since livewire v2 uses + * listeners to pass the value around. In livewire v3, this is fixed, and + * we can rename this trait to updatingCastLivewireProperties so that + * livewire uses the method directly. + */ + public function castLivewireProperties(string $field, mixed &$value): void + { + $class = new ReflectionClass(static::class); + + if (!$class->hasProperty($field)) { + return; + } + + if (($type = $class->getProperty($field)->getType()) instanceof ReflectionNamedType) { + if ($type->allowsNull() && $value === '') { + $value = null; + + return; + } + + switch ($type->getName()) { + case 'array': + $value = (array) $value; + + break; + case 'string': + validator([$field => $value], [$field => [ + function (string $attribute, mixed $value, Closure $fail): void { + if (!safe_string($value)) { + $fail(':attribute must be a string'); + } + }, + ]])->validate(); + + $value = (string) $value; + + break; + case 'int': + validator([$field => $value], [$field => [ + function (string $attribute, mixed $value, Closure $fail): void { + if (!safe_int($value)) { + $fail(':attribute must be a number'); + } + }, + ]])->validate(); + + $value = (int) $value; + + break; + case 'float': + validator([$field => $value], [$field => [ + function (string $attribute, mixed $value, Closure $fail): void { + if (!safe_float($value)) { + $fail(':attribute must be a float'); + } + }, + ]])->validate(); + + $value = (float) $value; + + break; + case 'bool': + $value = (bool) $value; + + break; + } + } + } +} diff --git a/app/Traits/LivewireSort.php b/app/Traits/LivewireSort.php new file mode 100644 index 0000000000..6682d74947 --- /dev/null +++ b/app/Traits/LivewireSort.php @@ -0,0 +1,28 @@ + + * @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0 + */ + +namespace App\Traits; + +trait LivewireSort +{ + final public function sortBy(string $field): void + { + if ($this->sortField === $field) { + $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; + } else { + $this->sortDirection = 'asc'; + } + + $this->sortField = $field; + } +} diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8678d25fb6..fab4a78f1d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -910,11 +910,6 @@ parameters: count: 1 path: app/Http/Controllers/User/GeneralSettingController.php - - - message: "#^Method App\\\\Http\\\\Livewire\\\\AttachmentUpload\\:\\:getAttachmentsProperty\\(\\) return type with generic class Illuminate\\\\Database\\\\Eloquent\\\\Collection does not specify its types\\: TKey, TModel$#" - count: 1 - path: app/Http/Livewire/AttachmentUpload.php - - message: "#^Property App\\\\Http\\\\Livewire\\\\AttachmentUpload\\:\\:\\$attachment has no type specified\\.$#" count: 1 @@ -930,41 +925,16 @@ parameters: count: 1 path: app/Http/Livewire/AuditLogSearch.php - - - message: "#^Method App\\\\Http\\\\Livewire\\\\AuditLogSearch\\:\\:getAuditsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/AuditLogSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\AuditLogSearch\\:\\:getModelNamesProperty\\(\\) has no return type specified\\.$#" - count: 1 - path: app/Http/Livewire/AuditLogSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\AuditLogSearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/AuditLogSearch.php - - message: "#^Cannot call method sizeInBytes\\(\\) on class\\-string\\|object\\.$#" count: 1 path: app/Http/Livewire/BackupPanel.php - - - message: "#^Method App\\\\Http\\\\Livewire\\\\BackupPanel\\:\\:getBackupStatusesProperty\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Http/Livewire/BackupPanel.php - - message: "#^Method App\\\\Http\\\\Livewire\\\\BackupPanel\\:\\:getBackupsProperty\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: app/Http/Livewire/BackupPanel.php - - - message: "#^Method App\\\\Http\\\\Livewire\\\\BackupPanel\\:\\:getDisksProperty\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Http/Livewire/BackupPanel.php - - message: "#^Property App\\\\Http\\\\Livewire\\\\BackupPanel\\:\\:\\$listeners has no type specified\\.$#" count: 1 @@ -995,26 +965,11 @@ parameters: count: 1 path: app/Http/Livewire/BlockIpAddress.php - - - message: "#^Property App\\\\Http\\\\Livewire\\\\BlockIpAddress\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/BlockIpAddress.php - - message: "#^Property App\\\\Http\\\\Livewire\\\\BlockIpAddress\\:\\:\\$rules has no type specified\\.$#" count: 1 path: app/Http/Livewire/BlockIpAddress.php - - - message: "#^Method App\\\\Http\\\\Livewire\\\\CollectionSearch\\:\\:getCollectionsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/CollectionSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\CollectionSearch\\:\\:\\$search has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/CollectionSearch.php - - message: "#^Call to an undefined method App\\\\Models\\\\User\\|Illuminate\\\\Database\\\\Eloquent\\\\Collection\\\\:\\:notify\\(\\)\\.$#" count: 4 @@ -1030,11 +985,6 @@ parameters: count: 1 path: app/Http/Livewire/Comment.php - - - message: "#^Property App\\\\Http\\\\Livewire\\\\Comment\\:\\:\\$anon has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/Comment.php - - message: "#^Property App\\\\Http\\\\Livewire\\\\Comment\\:\\:\\$comment has no type specified\\.$#" count: 1 @@ -1080,21 +1030,11 @@ parameters: count: 3 path: app/Http/Livewire/Comments.php - - - message: "#^Method App\\\\Http\\\\Livewire\\\\Comments\\:\\:getCommentsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/Comments.php - - message: "#^Method App\\\\Http\\\\Livewire\\\\Comments\\:\\:taggedUsers\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: app/Http/Livewire/Comments.php - - - message: "#^Property App\\\\Http\\\\Livewire\\\\Comments\\:\\:\\$anon has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/Comments.php - - message: "#^Property App\\\\Http\\\\Livewire\\\\Comments\\:\\:\\$listeners has no type specified\\.$#" count: 1 @@ -1120,106 +1060,11 @@ parameters: count: 1 path: app/Http/Livewire/Comments.php - - - message: "#^Method App\\\\Http\\\\Livewire\\\\CompanySearch\\:\\:getCompaniesProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/CompanySearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\CompanySearch\\:\\:\\$search has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/CompanySearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\FailedLoginSearch\\:\\:getFailedLoginsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/FailedLoginSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\FailedLoginSearch\\:\\:getFailedLoginsTop10IpProperty\\(\\) return type with generic class Illuminate\\\\Database\\\\Eloquent\\\\Collection does not specify its types\\: TKey, TModel$#" - count: 1 - path: app/Http/Livewire/FailedLoginSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\FailedLoginSearch\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/FailedLoginSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\FailedLoginSearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/FailedLoginSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\ForumCategoryTopicSearch\\:\\:getTopicsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/ForumCategoryTopicSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\ForumCategoryTopicSearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/ForumCategoryTopicSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\ForumTopicSearch\\:\\:getTopicsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/ForumTopicSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\ForumTopicSearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/ForumTopicSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\GiftLogSearch\\:\\:getGiftsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/GiftLogSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\GiftLogSearch\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/GiftLogSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\GiftLogSearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/GiftLogSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\HistorySearch\\:\\:getHistoriesProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/HistorySearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\HistorySearch\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/HistorySearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\HistorySearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/HistorySearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\InviteLogSearch\\:\\:getInvitesProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/InviteLogSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\InviteLogSearch\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/InviteLogSearch.php - - message: "#^Method App\\\\Http\\\\Livewire\\\\InviteLogSearch\\:\\:updatingGroupBy\\(\\) has parameter \\$value with no type specified\\.$#" count: 1 path: app/Http/Livewire/InviteLogSearch.php - - - message: "#^Property App\\\\Http\\\\Livewire\\\\InviteLogSearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/InviteLogSearch.php - - message: "#^Cannot access offset 0 on array\\\\|false\\.$#" count: 1 @@ -1240,81 +1085,11 @@ parameters: count: 1 path: app/Http/Livewire/LaravelLogViewer.php - - - message: "#^Property App\\\\Http\\\\Livewire\\\\LaravelLogViewer\\:\\:\\$logs has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/LaravelLogViewer.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\LaravelLogViewer\\:\\:\\$page has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/LaravelLogViewer.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\LaravelLogViewer\\:\\:\\$perPage has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/LaravelLogViewer.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\LaravelLogViewer\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/LaravelLogViewer.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\MissingMediaSearch\\:\\:getMediasProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/MissingMediaSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\MissingMediaSearch\\:\\:getTypesProperty\\(\\) return type with generic class Illuminate\\\\Database\\\\Eloquent\\\\Collection does not specify its types\\: TKey, TModel$#" - count: 1 - path: app/Http/Livewire/MissingMediaSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\MissingMediaSearch\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/MissingMediaSearch.php - - message: "#^Property App\\\\Http\\\\Livewire\\\\MissingMediaSearch\\:\\:\\$categories type has no value type specified in iterable type array\\.$#" count: 1 path: app/Http/Livewire/MissingMediaSearch.php - - - message: "#^Property App\\\\Http\\\\Livewire\\\\MissingMediaSearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/MissingMediaSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\NetworkSearch\\:\\:getNetworksProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/NetworkSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\NetworkSearch\\:\\:\\$search has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/NetworkSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\NoteSearch\\:\\:getNotesProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/NoteSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\NoteSearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/NoteSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\NotificationSearch\\:\\:getNotificationsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/NotificationSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\NotificationSearch\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/NotificationSearch.php - - message: "#^Method App\\\\Http\\\\Livewire\\\\PasswordStrength\\:\\:updatedPassword\\(\\) has parameter \\$password with no type specified\\.$#" count: 1 @@ -1325,21 +1100,6 @@ parameters: count: 1 path: app/Http/Livewire/PasswordStrength.php - - - message: "#^Method App\\\\Http\\\\Livewire\\\\PeerSearch\\:\\:getPeersProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/PeerSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\PeerSearch\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/PeerSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\PeerSearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/PeerSearch.php - - message: "#^Access to an undefined property App\\\\Models\\\\Movie\\:\\:\\$category_id\\.$#" count: 1 @@ -1360,26 +1120,11 @@ parameters: count: 1 path: app/Http/Livewire/PersonCredit.php - - - message: "#^Method App\\\\Http\\\\Livewire\\\\PersonCredit\\:\\:getMediasProperty\\(\\) return type with generic class Illuminate\\\\Support\\\\Collection does not specify its types\\: TKey, TValue$#" - count: 1 - path: app/Http/Livewire/PersonCredit.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\PersonCredit\\:\\:getPersonalFreeleechProperty\\(\\) has no return type specified\\.$#" - count: 1 - path: app/Http/Livewire/PersonCredit.php - - message: "#^Method App\\\\Http\\\\Livewire\\\\PersonCredit\\:\\:updatingOccupation\\(\\) has parameter \\$value with no type specified\\.$#" count: 1 path: app/Http/Livewire/PersonCredit.php - - - message: "#^Property App\\\\Http\\\\Livewire\\\\PersonCredit\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/PersonCredit.php - - message: "#^Property App\\\\Models\\\\Movie\\:\\:\\$torrents is not writable\\.$#" count: 1 @@ -1390,266 +1135,26 @@ parameters: count: 1 path: app/Http/Livewire/PersonCredit.php - - - message: "#^Method App\\\\Http\\\\Livewire\\\\PersonSearch\\:\\:getPersonsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/PersonSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\PersonSearch\\:\\:\\$search has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/PersonSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\PostSearch\\:\\:getPostsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/PostSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\PostSearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/PostSearch.php - - - - message: "#^Access to an undefined property App\\\\Models\\\\Movie\\|Illuminate\\\\Database\\\\Eloquent\\\\Collection\\\\:\\:\\$release_date\\.$#" - count: 1 - path: app/Http/Livewire/SimilarTorrent.php - - - - message: "#^Access to an undefined property App\\\\Models\\\\Movie\\|Illuminate\\\\Database\\\\Eloquent\\\\Collection\\\\:\\:\\$title\\.$#" - count: 1 - path: app/Http/Livewire/SimilarTorrent.php - - - - message: "#^Access to an undefined property App\\\\Models\\\\Tv\\|Illuminate\\\\Database\\\\Eloquent\\\\Collection\\\\:\\:\\$first_air_date\\.$#" - count: 1 - path: app/Http/Livewire/SimilarTorrent.php - - - - message: "#^Access to an undefined property App\\\\Models\\\\Tv\\|Illuminate\\\\Database\\\\Eloquent\\\\Collection\\\\:\\:\\$name\\.$#" - count: 1 - path: app/Http/Livewire/SimilarTorrent.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\SimilarTorrent\\:\\:getPersonalFreeleechProperty\\(\\) has no return type specified\\.$#" - count: 1 - path: app/Http/Livewire/SimilarTorrent.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\SimilarTorrent\\:\\:getTorrentRequestsProperty\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Http/Livewire/SimilarTorrent.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\SimilarTorrent\\:\\:getTorrentRequestsProperty\\(\\) return type has no value type specified in iterable type array\\|Illuminate\\\\Database\\\\Eloquent\\\\Collection\\.$#" - count: 1 - path: app/Http/Livewire/SimilarTorrent.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\SimilarTorrent\\:\\:getTorrentRequestsProperty\\(\\) return type with generic class Illuminate\\\\Database\\\\Eloquent\\\\Collection does not specify its types\\: TKey, TModel$#" - count: 1 - path: app/Http/Livewire/SimilarTorrent.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\SimilarTorrent\\:\\:getTorrentsProperty\\(\\) return type with generic class Illuminate\\\\Support\\\\Collection does not specify its types\\: TKey, TValue$#" - count: 1 - path: app/Http/Livewire/SimilarTorrent.php - - message: "#^Method App\\\\Http\\\\Livewire\\\\SimilarTorrent\\:\\:isChecked\\(\\) has parameter \\$torrentId with no type specified\\.$#" count: 1 path: app/Http/Livewire/SimilarTorrent.php - - - message: "#^Method App\\\\Http\\\\Livewire\\\\SimilarTorrent\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/SimilarTorrent.php - - message: "#^Method App\\\\Http\\\\Livewire\\\\SimilarTorrent\\:\\:updatedSelectPage\\(\\) has parameter \\$value with no type specified\\.$#" count: 1 path: app/Http/Livewire/SimilarTorrent.php - - - message: "#^Property App\\\\Http\\\\Livewire\\\\SimilarTorrent\\:\\:\\$checked has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/SimilarTorrent.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\SimilarTorrent\\:\\:\\$igdbId has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/SimilarTorrent.php - - message: "#^Property App\\\\Http\\\\Livewire\\\\SimilarTorrent\\:\\:\\$listeners has no type specified\\.$#" count: 1 path: app/Http/Livewire/SimilarTorrent.php - - - message: "#^Property App\\\\Http\\\\Livewire\\\\SimilarTorrent\\:\\:\\$reason has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/SimilarTorrent.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\SimilarTorrent\\:\\:\\$tmdbId has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/SimilarTorrent.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\SubscribedForum\\:\\:getForumsProperty\\(\\) has no return type specified\\.$#" - count: 1 - path: app/Http/Livewire/SubscribedForum.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\SubscribedTopic\\:\\:getTopicsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/SubscribedTopic.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\SubtitleSearch\\:\\:getSubtitlesProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/SubtitleSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\SubtitleSearch\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/SubtitleSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\SubtitleSearch\\:\\:\\$categories type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Http/Livewire/SubtitleSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\ThankButton\\:\\:mount\\(\\) has parameter \\$torrent with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/ThankButton.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\ThankButton\\:\\:\\$torrent has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/ThankButton.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\TicketSearch\\:\\:getTicketsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/TicketSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\TicketSearch\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/TicketSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TicketSearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/TicketSearch.php - - message: "#^Possibly invalid array key type \\(array\\|string\\)\\.$#" count: 2 path: app/Http/Livewire/Top10.php - - - message: "#^Method App\\\\Http\\\\Livewire\\\\TopicPostSearch\\:\\:getPostsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/TopicPostSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TopicPostSearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/TopicPostSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\TopicSearch\\:\\:getForumCategoriesProperty\\(\\) has no return type specified\\.$#" - count: 1 - path: app/Http/Livewire/TopicSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\TopicSearch\\:\\:getTopicsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/TopicSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TopicSearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/TopicSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\TorrentRequestSearch\\:\\:getTorrentRequestsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/TorrentRequestSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\TorrentRequestSearch\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/TorrentRequestSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentRequestSearch\\:\\:\\$categories type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Http/Livewire/TorrentRequestSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentRequestSearch\\:\\:\\$claimed has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/TorrentRequestSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentRequestSearch\\:\\:\\$filled has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/TorrentRequestSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentRequestSearch\\:\\:\\$genres type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Http/Livewire/TorrentRequestSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentRequestSearch\\:\\:\\$myClaims has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/TorrentRequestSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentRequestSearch\\:\\:\\$myFilled has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/TorrentRequestSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentRequestSearch\\:\\:\\$myRequests has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/TorrentRequestSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentRequestSearch\\:\\:\\$myVoted has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/TorrentRequestSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentRequestSearch\\:\\:\\$pending has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/TorrentRequestSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentRequestSearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/TorrentRequestSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentRequestSearch\\:\\:\\$resolutions type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Http/Livewire/TorrentRequestSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentRequestSearch\\:\\:\\$types type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Http/Livewire/TorrentRequestSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentRequestSearch\\:\\:\\$unfilled has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/TorrentRequestSearch.php - - message: "#^Access to an undefined property App\\\\Models\\\\Movie\\|Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\), mixed\\>\\:\\:\\$category_id\\.$#" count: 1 @@ -1685,246 +1190,31 @@ parameters: count: 1 path: app/Http/Livewire/TorrentSearch.php - - - message: "#^Method App\\\\Http\\\\Livewire\\\\TorrentSearch\\:\\:getGroupedPostersProperty\\(\\) has no return type specified\\.$#" - count: 1 - path: app/Http/Livewire/TorrentSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\TorrentSearch\\:\\:getGroupedTorrentsProperty\\(\\) has no return type specified\\.$#" - count: 1 - path: app/Http/Livewire/TorrentSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\TorrentSearch\\:\\:getPersonalFreeleechProperty\\(\\) has no return type specified\\.$#" - count: 1 - path: app/Http/Livewire/TorrentSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\TorrentSearch\\:\\:getTorrentsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/TorrentSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\TorrentSearch\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/TorrentSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentSearch\\:\\:\\$categories type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Http/Livewire/TorrentSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentSearch\\:\\:\\$distributors type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Http/Livewire/TorrentSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentSearch\\:\\:\\$free type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Http/Livewire/TorrentSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentSearch\\:\\:\\$genres type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Http/Livewire/TorrentSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentSearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/TorrentSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentSearch\\:\\:\\$regions type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Http/Livewire/TorrentSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentSearch\\:\\:\\$resolutions type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Http/Livewire/TorrentSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TorrentSearch\\:\\:\\$types type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Http/Livewire/TorrentSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\TvSearch\\:\\:getShowsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/TvSearch.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\TvSearch\\:\\:\\$search has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/TvSearch.php - - message: "#^Access to an undefined property App\\\\Models\\\\User\\:\\:\\$two_factor_confirmed_at\\.$#" count: 1 path: app/Http/Livewire/TwoFactorAuthForm.php - - - message: "#^Method App\\\\Http\\\\Livewire\\\\UserActive\\:\\:getActivesProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/UserActive.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\UserActive\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/UserActive.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\UserActive\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/UserActive.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\UserActive\\:\\:\\$showMorePrecision has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/UserActive.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\UserNotes\\:\\:getNotesProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/UserNotes.php - - message: "#^Property App\\\\Http\\\\Livewire\\\\UserNotes\\:\\:\\$rules has no type specified\\.$#" count: 1 path: app/Http/Livewire/UserNotes.php - - - message: "#^Method App\\\\Http\\\\Livewire\\\\UserResurrections\\:\\:getResurrectionsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/UserResurrections.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\UserResurrections\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/UserResurrections.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\UserResurrections\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/UserResurrections.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\UserSearch\\:\\:getUsersProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/UserSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\UserSearch\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/UserSearch.php - - message: "#^Method App\\\\Http\\\\Livewire\\\\UserSearch\\:\\:toggleProperties\\(\\) has parameter \\$property with no type specified\\.$#" count: 1 path: app/Http/Livewire/UserSearch.php - - - message: "#^Property App\\\\Http\\\\Livewire\\\\UserSearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/UserSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\UserTorrents\\:\\:getHistoryProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/UserTorrents.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\UserTorrents\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/UserTorrents.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\UserTorrents\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/UserTorrents.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\UserTorrents\\:\\:\\$showMorePrecision has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/UserTorrents.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\UserTorrents\\:\\:\\$status type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Http/Livewire/UserTorrents.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\UserUploads\\:\\:getUploadsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/UserUploads.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\UserUploads\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/UserUploads.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\UserUploads\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/UserUploads.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\UserUploads\\:\\:\\$showMorePrecision has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/UserUploads.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\UserUploads\\:\\:\\$status type has no value type specified in iterable type array\\.$#" - count: 1 - path: app/Http/Livewire/UserUploads.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\UserWarnings\\:\\:getWarningsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/UserWarnings.php - - - - message: "#^Property App\\\\Http\\\\Livewire\\\\UserWarnings\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/UserWarnings.php - - message: "#^Property App\\\\Http\\\\Livewire\\\\UserWarnings\\:\\:\\$rules has no type specified\\.$#" count: 1 path: app/Http/Livewire/UserWarnings.php - - - message: "#^Method App\\\\Http\\\\Livewire\\\\WarningLogSearch\\:\\:getWarningsProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/WarningLogSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\WarningLogSearch\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/WarningLogSearch.php - - message: "#^Method App\\\\Http\\\\Livewire\\\\WarningLogSearch\\:\\:toggleProperties\\(\\) has parameter \\$property with no type specified\\.$#" count: 1 path: app/Http/Livewire/WarningLogSearch.php - - - message: "#^Property App\\\\Http\\\\Livewire\\\\WarningLogSearch\\:\\:\\$queryString has no type specified\\.$#" - count: 1 - path: app/Http/Livewire/WarningLogSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\WatchlistSearch\\:\\:getUsersProperty\\(\\) return type with generic interface Illuminate\\\\Contracts\\\\Pagination\\\\LengthAwarePaginator does not specify its types\\: TItem$#" - count: 1 - path: app/Http/Livewire/WatchlistSearch.php - - - - message: "#^Method App\\\\Http\\\\Livewire\\\\WatchlistSearch\\:\\:sortBy\\(\\) has parameter \\$field with no type specified\\.$#" - count: 1 - path: app/Http/Livewire/WatchlistSearch.php - - message: "#^Method App\\\\Http\\\\Middleware\\\\SetLanguage\\:\\:setSystemLocale\\(\\) has parameter \\$request with no type specified\\.$#" count: 1 diff --git a/resources/views/livewire/torrent-search.blade.php b/resources/views/livewire/torrent-search.blade.php index b4b60ebbfd..019e7e5956 100644 --- a/resources/views/livewire/torrent-search.blade.php +++ b/resources/views/livewire/torrent-search.blade.php @@ -80,6 +80,8 @@ class="form__text" id="startYear" wire:model="startYear" class="form__text" + inputmode="numeric" + pattern="[0-9]*" placeholder=" " />