@extends('layouts.master') @section('title') Client logs @endsection @section('css') @endsection @section('content') @component('components.breadcrumb') @slot('li_1') Admin @endslot @slot('title') Logs @endslot @endcomponent
@if($errors->any())
    @foreach($errors->all() as $error)
  • {{ $error }}
  • @endforeach
@endif @if(session('success')) @endif @if(session('error')) @endif @include('components.export-buttons')
@php use Spatie\Activitylog\Models\Activity; use App\Models\User; // Get distinct causer_ids from logs $causerIds = Activity::whereNotNull('causer_id')->distinct()->pluck('causer_id'); // Get users that still exist in the DB $existingUsers = User::whereIn('id', $causerIds)->get()->keyBy('id'); // Prepare the list for dropdown (id => name) $causerOptions = []; foreach ($causerIds as $id) { if (isset($existingUsers[$id])) { $user = $existingUsers[$id]; $causerOptions[$id] = "{$user->firstname} {$user->lastname}"; } else { // Fetch the latest log with that causer_id and extract fallback name $log = Activity::where('causer_id', $id)->latest()->first(); $fallbackName = 'Unknown'; if ($log && $log->properties) { $props = json_decode($log->properties); $fallbackName = $props->causer_name ?? 'Deleted User'; } $causerOptions[$id] = "{$fallbackName} (Deleted)"; } } @endphp {{-- Causer (User) Filter --}}
{{-- Start Date --}}
{{-- End Date --}}
{{-- Search Text --}}
{{-- Actions --}}
Reset
Action Subject Description User User Agent Date
@endsection @section('script') @endsection