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\Domain\Product;
use HiEvents\DomainObjects\ProductDomainObject;
use HiEvents\Repository\Interfaces\ProductRepositoryInterface;
use HiEvents\Services\Domain\Product\Exception\UnrecognizedProductIdException;
class EventProductValidationService
{
public function __construct(
private readonly ProductRepositoryInterface $productRepository,
) {}
/**
* @throws UnrecognizedProductIdException
*/
public function validateProductIds(array $productIds, int $eventId): void
{
$validProductIds = $this->productRepository->findWhere([
'event_id' => $eventId,
])->map(fn (ProductDomainObject $product) => $product->getId())
->toArray();
$invalidProductIds = array_diff($productIds, $validProductIds);
if (! empty($invalidProductIds)) {
throw new UnrecognizedProductIdException(
__('Invalid product ids: :ids', ['ids' => implode(', ', $invalidProductIds)])
);
}
}
}