country = request()->route('country'); } public function sort($column) { if ($this->sortBy === $column) { $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; } else { $this->sortBy = $column; $this->sortDirection = 'asc'; } } public function with(): array { return [ 'lecturers' => Lecturer::with(['createdBy']) ->when($this->search, fn($query) => $query->where('name', 'ilike', '%'.$this->search.'%') ->orWhere('description', 'ilike', '%'.$this->search.'%') ->orWhere('subtitle', 'ilike', '%'.$this->search.'%'), ) ->orderBy($this->sortBy, $this->sortDirection) ->paginate(15), ]; } }; ?>