feat: establish reservation portal foundation

This commit is contained in:
2026-08-04 15:24:08 +01:00
commit c96264ae96
226 changed files with 32232 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Domain\Reservations\Services;
use App\Domain\Inventory\Models\SnipeAsset;
use App\Domain\Reservations\Enums\ReservationItemStatus;
use DateTimeInterface;
class AvailabilityService
{
public function isAvailable(SnipeAsset $asset, DateTimeInterface $startsAt, DateTimeInterface $endsAt): bool
{
if (! $asset->active || ! $asset->requestable || $asset->assigned_id !== null) {
return false;
}
$hasReservationConflict = $asset->reservationItems()
->whereIn('status', ReservationItemStatus::blockingValues())
->where('starts_at', '<', $endsAt)
->where('ends_at', '>', $startsAt)
->exists();
if ($hasReservationConflict) {
return false;
}
return ! $asset->blocks()
->where('starts_at', '<', $endsAt)
->where('ends_at', '>', $startsAt)
->exists();
}
}