<?php namespace App\Services; use App\Models\AuditLog; use Illuminate\Http\Request;
class AuditService { public function log(?int $userId,string $action,?string $targetType=null,?int $targetId=null,array $old=[],array $new=[],array $meta=[],?Request $request=null): void { AuditLog::create(['user_id'=>$userId,'action'=>$action,'target_type'=>$targetType,'target_id'=>$targetId,'ip_address'=>$request?->ip(),'user_agent'=>$request?->userAgent(),'old_values'=>$old?:null,'new_values'=>$new?:null,'meta'=>$meta?:null,'created_at'=>now()]); } }
