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
declare(strict_types=1);
namespace HiEvents\Services\Domain\Location;
use HiEvents\Exceptions\ResourceNotFoundException;
use HiEvents\Repository\Interfaces\LocationRepositoryInterface;
class LocationOwnershipValidator
{
public function __construct(
private readonly LocationRepositoryInterface $locationRepository,
private readonly LocationLockService $locationLockService,
) {}
/**
* @throws ResourceNotFoundException
*/
public function assertOwnedBy(?int $locationId, int $organizerId, int $accountId): void
{
if ($locationId === null) {
return;
}
$this->locationLockService->acquireSharedTransactionLock($locationId);
$location = $this->locationRepository->findFirstWhere([
'id' => $locationId,
'account_id' => $accountId,
'organizer_id' => $organizerId,
]);
if ($location === null) {
throw new ResourceNotFoundException(
__('Location :id not found', ['id' => $locationId]),
);
}
}
}