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') }}

{{ __('timelines.timelines_description') }}

{{ __('export.export_timelines') }} {{ __('timelines.create_timeline') }}
@if(session('success')) {{ session('success') }} @endif @if(session('error')) {{ session('error') }} @endif
@foreach($clients as $client) @endforeach @foreach($statuses as $status) @endforeach {{ __('admin.per_page') }}
{{ __('admin.date_from') }} {{ __('admin.date_to') }} @if($search || $clientFilter || $statusFilter || $dateFrom || $dateTo) {{ __('common.clear') }} @endif
@forelse($timelines as $timeline)
{{ $timeline->case_name }} @if($timeline->case_reference)
{{ __('timelines.reference') }}: {{ $timeline->case_reference }}
@endif
{{ $timeline->user->full_name }}
{{ $timeline->user->email }}
{{ $timeline->status->label() }}
{{ $timeline->updated_at->diffForHumans() }}
{{ $timeline->created_at->format('Y-m-d') }}
{{ $timeline->updates_count }}
{{ __('timelines.view') }} {{ __('timelines.view') }} @if($timeline->isActive()) {{ __('timelines.add_update') }} @endif {{ $timeline->isActive() ? __('timelines.archive') : __('timelines.unarchive') }}
@empty

{{ __('timelines.no_timelines') }}

@endforelse
{{ $timelines->links() }}