feat: protect production Snipe-IT operations

This commit is contained in:
2026-08-05 12:37:12 +01:00
parent 26330b75f7
commit 8c69331118
13 changed files with 289 additions and 26 deletions

View File

@@ -27,6 +27,22 @@ final readonly class AssetData
public ?CarbonImmutable $sourceUpdatedAt,
) {}
public function isAssigned(): bool
{
return $this->assignedType !== null || $this->assignedId !== null;
}
public function isAssignedToUser(int $userId): bool
{
if ($this->assignedId !== $userId || $this->assignedType === null) {
return false;
}
$normalizedType = strtolower(str_replace(['\\', '_', '-', ' '], '', $this->assignedType));
return str_ends_with($normalizedType, 'user');
}
/** @return array<string, mixed> */
public function toModelAttributes(): array
{