latest
This commit is contained in:
1 parent
d0834df8df
commit
6dc35134fa
171 files changed
+19241
-49
No files matched your search
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Audit;
|
||||
|
||||
use App\Models\AuditLog;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
|
||||
class AuditLogger
|
||||
{
|
||||
public function log(User $actor, string $action, ?Model $auditable = null, array $metadata = []): AuditLog
|
||||
{
|
||||
return AuditLog::create([
|
||||
'user_id' => $actor->id,
|
||||
'action' => $action,
|
||||
'auditable_type' => $auditable?->getMorphClass(),
|
||||
'auditable_id' => $auditable?->getKey(),
|
||||
'ip_address' => Request::ip(),
|
||||
'user_agent' => Request::userAgent(),
|
||||
'metadata' => $metadata,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user