23 lines
609 B
PHP
23 lines
609 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Models\ActivityLog;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class ActivityLogService
|
|
{
|
|
public function log(string $action, string $description, ?string $targetType = null, ?int $targetId = null, ?array $meta = null, ?int $userId = null): void
|
|
{
|
|
ActivityLog::create([
|
|
'user_id' => $userId ?? Auth::id(),
|
|
'action' => $action,
|
|
'target_type' => $targetType,
|
|
'target_id' => $targetId,
|
|
'description' => $description,
|
|
'meta' => $meta,
|
|
'created_at' => now(),
|
|
]);
|
|
}
|
|
}
|