adds logging and policies
This commit is contained in:
29
app/Services/ActivityLogger.php
Normal file
29
app/Services/ActivityLogger.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Log;
|
||||
|
||||
final class ActivityLogger
|
||||
{
|
||||
/**
|
||||
* Log an activity to the database.
|
||||
*/
|
||||
public static function log(
|
||||
string $action,
|
||||
?int $userId = null,
|
||||
?int $sessionId = null,
|
||||
?int $categoryId = null,
|
||||
?array $metadata = null,
|
||||
): void {
|
||||
Log::create([
|
||||
'user_id' => $userId,
|
||||
'session_id' => $sessionId,
|
||||
'category_id' => $categoryId,
|
||||
'action' => $action,
|
||||
'metadata' => $metadata,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user