resetPage(); } public function updatedClientFilter(): void { $this->resetPage(); } public function updatedStatusFilter(): void { $this->resetPage(); } public function updatedDateFrom(): void { $this->resetPage(); } public function updatedDateTo(): 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->clientFilter = ''; $this->statusFilter = ''; $this->dateFrom = ''; $this->dateTo = ''; $this->resetPage(); } public function toggleArchive(int $id): void { $timeline = Timeline::findOrFail($id); if ($timeline->isArchived()) { $timeline->unarchive(); $action = 'unarchive'; $message = __('messages.timeline_unarchived'); } else { $timeline->archive(); $action = 'archive'; $message = __('messages.timeline_archived'); } AdminLog::create([ 'admin_id' => auth()->id(), 'action' => $action, 'target_type' => 'timeline', 'target_id' => $timeline->id, 'ip_address' => request()->ip(), 'created_at' => now(), ]); session()->flash('success', $message); } public function with(): array { return [ 'timelines' => Timeline::query() ->with(['user:id,full_name,email', 'updates' => fn ($q) => $q->latest()->limit(1)]) ->withCount('updates') ->when($this->search, fn ($q) => $q->where(function ($q) { $q->where('case_name', 'like', "%{$this->search}%") ->orWhere('case_reference', 'like', "%{$this->search}%"); })) ->when($this->clientFilter, fn ($q) => $q->where('user_id', $this->clientFilter)) ->when($this->statusFilter, fn ($q) => $q->where('status', $this->statusFilter)) ->when($this->dateFrom, fn ($q) => $q->where('created_at', '>=', $this->dateFrom)) ->when($this->dateTo, fn ($q) => $q->where('created_at', '<=', $this->dateTo . ' 23:59:59')) ->orderBy($this->sortBy, $this->sortDir) ->paginate($this->perPage), 'clients' => User::query() ->whereHas('timelines') ->orderBy('full_name') ->get(['id', 'full_name']), 'statuses' => TimelineStatus::cases(), ]; } }; ?>
{{ __('timelines.timelines_description') }}
{{ __('timelines.no_timelines') }}