Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
<?php
namespace HiEvents\Services\Application\Handlers\CheckInList;
use HiEvents\Enterprise\BoxOffice\Repository\Interfaces\BoxOfficeRepositoryInterface;
use HiEvents\Exceptions\ResourceConflictException;
use HiEvents\Repository\Interfaces\CheckInListRepositoryInterface;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
class DeleteCheckInListHandler
{
public function __construct(
private readonly CheckInListRepositoryInterface $checkInListRepository,
private readonly BoxOfficeRepositoryInterface $boxOfficeRepository,
) {}
public function handle(int $eventId, int $checkInListId): void
{
$checkInList = $this->checkInListRepository
->findFirstWhere([
'event_id' => $eventId,
'id' => $checkInListId,
]);
if ($checkInList === null) {
throw new ResourceNotFoundException(__('Check-in list not found'));
}
if ($checkInList->getIsSystemDefault()) {
throw new ResourceConflictException(
__('The default check-in list can\'t be deleted.')
);
}
$this->boxOfficeRepository->updateWhere(
attributes: ['check_in_list_id' => null],
where: ['check_in_list_id' => $checkInListId],
);
$this->checkInListRepository->deleteWhere([
'id' => $checkInListId,
'event_id' => $eventId,
]);
}
}