<?php

namespace App\Http\Controllers;


use Illuminate\Support\Facades\Auth;
use Spatie\Activitylog\Models\Activity;



class AuditController extends Controller 
{
    public function index(){
        $currentUser = Auth::user();

        $audits = Activity::with(['causer', 'subject'])
                ->whereHas('causer', function ($query) use ($currentUser) {
                    $query->where('organisation_id', $currentUser->organisation_id);
                })
                ->latest()
                ->paginate(10);

        return view('audit_trail.index', compact('audits'));
    }
}