Files
minicrm/app/Services/ActivityLogger.php
phuongtc efa97b6c71
Some checks failed
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled
Tests / PHP 8.5 (push) Has been cancelled
them log, chinh upload
2026-05-09 11:00:59 +00:00

28 lines
691 B
PHP

<?php
namespace App\Services;
use App\Models\ActivityLog;
use Illuminate\Database\Eloquent\Model;
class ActivityLogger
{
public static function log(
string $action,
string $description,
?Model $subject = null,
?array $metadata = null,
?int $userId = null,
): ActivityLog {
return ActivityLog::create([
'user_id' => $userId ?? auth()->id(),
'action' => $action,
'description' => $description,
'subject_type' => $subject ? get_class($subject) : null,
'subject_id' => $subject?->id,
'metadata' => $metadata,
'created_at' => now(),
]);
}
}