Implementa reforcos orcamentais com aprovacao independente

This commit is contained in:
2026-10-28 15:03:49 +02:00
parent c41628d738
commit 153ba2c1af
24 changed files with 1023 additions and 25 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace App\Models;
use App\Models\Concerns\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
/** @property int $id
* @property int $tenant_id
* @property int $budget_id
* @property int $created_by
* @property int $amount_minor
* @property string $status
* @property string $payload_hash
*/
class BudgetReinforcement extends Model
{
use BelongsToTenant;
protected $guarded = ['id'];
protected $attributes = ['status' => 'pending'];
protected $hidden = ['payload_hash'];
protected static function booted(): void
{
static::updating(function (BudgetReinforcement $reinforcement) {
if ($reinforcement->getRawOriginal('status') !== 'pending' || array_diff(array_keys($reinforcement->getDirty()), ['status', 'reviewed_by', 'review_reason', 'reviewed_at', 'updated_at']) !== []) {
throw new \LogicException('Preservar o reforço e a decisão.');
}
});
static::deleting(fn () => throw new \LogicException('Não eliminar reforços orçamentais.'));
}
}