commit compras2 2811
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-28 15:45:52 +02:00
parent eb32c74c56
commit 060c119ba1
92 changed files with 4936 additions and 43 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ namespace App\Models;
use App\Enums\PurchasingRole;
use App\Models\Concerns\BelongsToTenant;
use App\Services\ConflictReleases;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -41,7 +42,7 @@ class ConflictDeclaration extends Model
/** @param Builder<ConflictDeclaration> $query */
public function scopeVisibleTo(Builder $query, User $user): void
{
if (! $user->hasFunctions([PurchasingRole::Admin, PurchasingRole::Finance])) {
if (! $user->hasFunctions([PurchasingRole::Admin, PurchasingRole::Finance]) && ! app(ConflictReleases::class)->canAuthorise($user)) {
$query->where('user_id', $user->id);
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace App\Models;
use App\Models\Concerns\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use LogicException;
class ConflictRelease extends Model
{
use BelongsToTenant;
public $timestamps = false;
protected $guarded = ['id'];
protected function casts(): array
{
return ['snapshot' => 'array', 'authorised_at' => 'datetime'];
}
protected static function booted(): void
{
static::updating(fn () => throw new LogicException('Preservar a autorização da direcção.'));
static::deleting(fn () => throw new LogicException('Preservar o histórico do levantamento.'));
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace App\Models;
use App\Models\Concerns\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use LogicException;
/** @property list<string> $families */
class PrivateAuditExport extends Model
{
use BelongsToTenant;
public $timestamps = false;
protected $guarded = ['id'];
protected $hidden = ['path', 'input_hash'];
protected function casts(): array
{
return ['families' => 'array', 'manifest' => 'array', 'created_at' => 'datetime', 'size' => 'integer'];
}
protected static function booted(): void
{
static::updating(fn () => throw new LogicException('Preservar o pacote e o manifesto originais da auditoria.'));
static::deleting(fn () => throw new LogicException('Preservar o histórico da exportação privada.'));
}
}