Valida concorrencia e aplica orcamento com recuperacao verificada
This commit is contained in:
@@ -16,6 +16,20 @@ class Budget extends Model
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::updating(function (Budget $budget) {
|
||||
if ($budget->getRawOriginal('approved_by') !== null) {
|
||||
throw new \LogicException('Uma dotação aprovada não pode ser reescrita.');
|
||||
}
|
||||
});
|
||||
static::deleting(function (Budget $budget) {
|
||||
if ($budget->approved_by !== null) {
|
||||
throw new \LogicException('Preservar a dotação aprovada e os seus movimentos.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['includes_tax' => 'boolean'];
|
||||
|
||||
Reference in New Issue
Block a user