feat: phase 3 — stock balances, restock/adjust mutations with activity logging, movements page
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Services\InsForge\InsForgeClient;
|
||||
|
||||
class ActivityLogger
|
||||
{
|
||||
public function __construct(private readonly InsForgeClient $client) {}
|
||||
|
||||
public function log(string $action, string $entityType, ?string $entityId, string $description, ?User $actor = null): void
|
||||
{
|
||||
$entry = array_filter([
|
||||
'user_id' => $actor?->id,
|
||||
'action' => $action,
|
||||
'entity_type' => $entityType,
|
||||
'entity_id' => $entityId,
|
||||
'description' => $description,
|
||||
], fn ($value) => $value !== null && $value !== '');
|
||||
|
||||
$this->client->insertRecord('activity_logs', [$entry], asUser: false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user