feat: phase 3 — stock balances, restock/adjust mutations with activity logging, movements page

This commit is contained in:
sean
2026-08-25 18:46:03 +07:00
parent 4298544381
commit 002fdce854
7 changed files with 601 additions and 2 deletions
+24
View File
@@ -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);
}
}