timeline = $timeline->load(['user', 'updates.admin']); } public function rules(): array { return [ 'updateText' => ['required', 'string', 'min:10'], ]; } public function messages(): array { return [ 'updateText.required' => __('timelines.update_text_required'), 'updateText.min' => __('timelines.update_text_min'), ]; } public function addUpdate(): void { if ($this->timeline->isArchived()) { session()->flash('error', __('messages.cannot_update_archived_timeline')); return; } $this->validate(); $update = $this->timeline->updates()->create([ 'admin_id' => auth()->id(), 'update_text' => clean($this->updateText), ]); if ($this->timeline->user->isActive()) { $this->timeline->user->notify(new TimelineUpdateNotification($update)); } AdminLog::create([ 'admin_id' => auth()->id(), 'action' => 'create', 'target_type' => 'timeline_update', 'target_id' => $update->id, 'new_values' => $update->toArray(), 'ip_address' => request()->ip(), 'created_at' => now(), ]); $this->updateText = ''; $this->timeline->load(['updates.admin']); session()->flash('success', __('messages.update_added')); } public function editUpdate(int $updateId): void { $update = $this->timeline->updates()->findOrFail($updateId); $this->editingUpdateId = $updateId; $this->updateText = $update->update_text; } public function saveEdit(): void { $this->validate(); $update = $this->timeline->updates()->findOrFail($this->editingUpdateId); $oldText = $update->update_text; $update->update([ 'update_text' => clean($this->updateText), ]); AdminLog::create([ 'admin_id' => auth()->id(), 'action' => 'update', 'target_type' => 'timeline_update', 'target_id' => $update->id, 'old_values' => ['update_text' => $oldText], 'new_values' => ['update_text' => clean($this->updateText)], 'ip_address' => request()->ip(), 'created_at' => now(), ]); $this->editingUpdateId = null; $this->updateText = ''; $this->timeline->load(['updates.admin']); session()->flash('success', __('messages.update_edited')); } public function cancelEdit(): void { $this->editingUpdateId = null; $this->updateText = ''; } public function archive(): void { if ($this->timeline->isArchived()) { return; } $this->timeline->archive(); AdminLog::create([ 'admin_id' => auth()->id(), 'action' => 'archive', 'target_type' => 'timeline', 'target_id' => $this->timeline->id, 'ip_address' => request()->ip(), 'created_at' => now(), ]); session()->flash('success', __('messages.timeline_archived')); } public function unarchive(): void { if ($this->timeline->isActive()) { return; } $this->timeline->unarchive(); AdminLog::create([ 'admin_id' => auth()->id(), 'action' => 'unarchive', 'target_type' => 'timeline', 'target_id' => $this->timeline->id, 'ip_address' => request()->ip(), 'created_at' => now(), ]); session()->flash('success', __('messages.timeline_unarchived')); } }; ?>
{{ __('timelines.back_to_timelines') }}
{{-- Timeline Header --}}
{{ $timeline->case_name }} @if($timeline->case_reference)
{{ __('timelines.reference') }}: {{ $timeline->case_reference }}
@endif
{{ $timeline->status->label() }} @if($timeline->isActive()) {{ __('timelines.archive') }} @else {{ __('timelines.unarchive') }} @endif
{{ $timeline->user->full_name }}
{{ $timeline->user->email }}
{{ __('timelines.created') }}: {{ $timeline->created_at->format('Y-m-d') }}
{{-- Flash Messages --}} @if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif {{-- Add Update Form --}}
{{ __('timelines.add_update') }} @if($timeline->isArchived()) {{ __('timelines.archived_notice') }} @else
{{ __('timelines.update_text') }} * {{ __('timelines.update_min_chars') }}
@if($editingUpdateId) {{ __('timelines.save_edit') }} {{ __('timelines.cancel') }} @else {{ __('timelines.add_update_button') }} @endif
@endif
{{-- Timeline Updates --}}
{{ __('timelines.updates_history') }} @if($timeline->updates->isEmpty())
{{ __('timelines.no_updates') }}
@else
{{-- Timeline line --}}
@foreach($timeline->updates as $update)
{{-- Timeline dot --}}
{{-- Update content --}}
{{ $update->admin->full_name }} {{ $update->created_at->format('Y-m-d H:i') }} @if($update->updated_at->gt($update->created_at)) {{ __('timelines.edited') }} @endif
@if(!$editingUpdateId && $timeline->isActive()) {{ __('timelines.edit') }} @endif
{!! $update->update_text !!}
@endforeach
@endif
{{-- Archive Confirmation Modal --}}
{{ __('timelines.archive_confirm_title') }} {{ __('timelines.archive_confirm_message') }}
{{ __('timelines.cancel') }} {{ __('timelines.archive') }}