feat: add transactional approval workflow
This commit is contained in:
@@ -25,14 +25,19 @@ class AvailabilityService
|
||||
->where('ends_at', '>', $startsAt));
|
||||
}
|
||||
|
||||
public function isAvailable(SnipeAsset $asset, DateTimeInterface $startsAt, DateTimeInterface $endsAt): bool
|
||||
{
|
||||
public function isAvailable(
|
||||
SnipeAsset $asset,
|
||||
DateTimeInterface $startsAt,
|
||||
DateTimeInterface $endsAt,
|
||||
?int $exceptReservationId = null,
|
||||
): bool {
|
||||
if (! $asset->active || ! $asset->requestable || $asset->assigned_id !== null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$hasReservationConflict = $asset->reservationItems()
|
||||
->whereIn('status', ReservationItemStatus::blockingValues())
|
||||
->when($exceptReservationId, fn (Builder $query): Builder => $query->where('reservation_id', '!=', $exceptReservationId))
|
||||
->where('starts_at', '<', $endsAt)
|
||||
->where('ends_at', '>', $startsAt)
|
||||
->exists();
|
||||
|
||||
Reference in New Issue
Block a user