feat: protect production Snipe-IT operations
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user