resetPage(); } public function updatedStatusFilter(): void { $this->resetPage(); } public function updatedPerPage(): void { $this->resetPage(); } public function sort(string $column): void { if ($this->sortBy === $column) { $this->sortDir = $this->sortDir === 'asc' ? 'desc' : 'asc'; } else { $this->sortBy = $column; $this->sortDir = 'asc'; } } public function clearFilters(): void { $this->search = ''; $this->statusFilter = ''; $this->resetPage(); } public function with(): array { $locale = app()->getLocale(); return [ 'posts' => Post::query() ->when($this->search, fn ($q) => $q->where(function ($q) use ($locale) { $q->whereRaw("JSON_EXTRACT(title, '$.\"{$locale}\"') LIKE ?", ["%{$this->search}%"]) ->orWhereRaw("JSON_EXTRACT(title, '$.\"ar\"') LIKE ?", ["%{$this->search}%"]) ->orWhereRaw("JSON_EXTRACT(title, '$.\"en\"') LIKE ?", ["%{$this->search}%"]); })) ->when($this->statusFilter, fn ($q) => $q->where('status', $this->statusFilter)) ->orderBy($this->sortBy, $this->sortDir) ->paginate($this->perPage), 'statuses' => PostStatus::cases(), ]; } }; ?>
{{ __('posts.posts_description') }}
{{ __('posts.no_posts') }}