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\Application\Handlers\EventOccurrence;
use HiEvents\DomainObjects\EventLocationDomainObject;
use HiEvents\DomainObjects\EventOccurrenceStatisticDomainObject;
use HiEvents\DomainObjects\LocationDomainObject;
use HiEvents\Http\DTO\QueryParamsDTO;
use HiEvents\Repository\Eloquent\Value\Relationship;
use HiEvents\Repository\Interfaces\EventOccurrenceRepositoryInterface;
use HiEvents\Services\Domain\EventOccurrence\OccurrenceBookingLimitsService;
use Illuminate\Pagination\LengthAwarePaginator;
class GetEventOccurrencesHandler
{
public function __construct(
private readonly EventOccurrenceRepositoryInterface $occurrenceRepository,
private readonly OccurrenceBookingLimitsService $bookingLimitsService,
) {}
public function handle(int $eventId, QueryParamsDTO $queryParams, bool $includeStats = true): LengthAwarePaginator
{
$repository = $this->occurrenceRepository
->loadRelation(new Relationship(domainObject: EventLocationDomainObject::class, name: 'event_location', nested: [
new Relationship(domainObject: LocationDomainObject::class, name: 'location'),
]));
if ($includeStats) {
$repository = $repository->loadRelation(EventOccurrenceStatisticDomainObject::class);
}
$occurrences = $repository->findByEventId($eventId, $queryParams);
$this->bookingLimitsService->attachTo($occurrences->getCollection(), $eventId);
return $occurrences;
}
}