# Story 6.10: Audit Log Viewer ## Epic Reference **Epic 6:** Admin Dashboard ## User Story As an **admin**, I want **to view admin action history**, So that **I can maintain accountability and track changes**. ## Acceptance Criteria ### Display - [ ] Action type (create, update, delete) - [ ] Target (user, consultation, timeline, etc.) - [ ] Old and new values (for updates) - [ ] Timestamp - [ ] IP address ### Filtering - [ ] Filter by action type - [ ] Filter by target type - [ ] Filter by date range ### Search - [ ] Search by target name/ID ### Features - [ ] Pagination - [ ] Export audit log (CSV) ## Technical Notes ```php new class extends Component { use WithPagination; public string $actionFilter = ''; public string $targetFilter = ''; public string $dateFrom = ''; public string $dateTo = ''; public string $search = ''; public function with(): array { return [ 'logs' => AdminLog::query() ->with('admin') ->when($this->actionFilter, fn($q) => $q->where('action_type', $this->actionFilter)) ->when($this->targetFilter, fn($q) => $q->where('target_type', $this->targetFilter)) ->when($this->dateFrom, fn($q) => $q->whereDate('created_at', '>=', $this->dateFrom)) ->when($this->dateTo, fn($q) => $q->whereDate('created_at', '<=', $this->dateTo)) ->when($this->search, fn($q) => $q->where('target_id', $this->search)) ->latest() ->paginate(25), 'actionTypes' => AdminLog::distinct()->pluck('action_type'), 'targetTypes' => AdminLog::distinct()->pluck('target_type'), ]; } public function exportCsv() { // Export filtered logs to CSV } }; ``` ### Template ```blade @foreach($logs as $log)