feat: Add tenant code to value changes; implement PurchaseController and related services for tenant-specific purchase management

This commit is contained in:
2026-08-04 10:27:33 -03:00
parent 96f26e2e9d
commit 3f9bcd84c4
11 changed files with 222 additions and 0 deletions

View File

@@ -11,6 +11,8 @@ use LogicException;
trait LogsValueChanges
{
abstract protected function valueChangeTenantCode(): string;
public static function bootLogsValueChanges(): void
{
static::updated(function (Model $model): void {
@@ -30,6 +32,7 @@ trait LogsValueChanges
foreach ($changedAttributes as $attribute) {
$model->valueChanges()->create([
'tenant_code' => $model->valueChangeTenantCode(),
'attribute' => $attribute,
'old_value' => $model->getRawOriginal($attribute),
'new_value' => $model->getAttributes()[$attribute] ?? null,