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\Resources\CapacityAssignment;
use HiEvents\DomainObjects\CapacityAssignmentDomainObject;
use HiEvents\DomainObjects\Enums\CapacityAssignmentAppliesTo;
use HiEvents\DomainObjects\ProductDomainObject;
use HiEvents\Resources\BaseResource;
use Illuminate\Http\Request;
/**
* @mixin CapacityAssignmentDomainObject
*/
class CapacityAssignmentResource extends BaseResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->getId(),
'name' => $this->getName(),
'capacity' => $this->getCapacity(),
'used_capacity' => $this->getUsedCapacity(),
'percentage_used' => $this->getPercentageUsed(),
'applies_to' => $this->getAppliesTo(),
'status' => $this->getStatus(),
'event_id' => $this->getEventId(),
$this->mergeWhen(
condition: $this->getProducts() !== null && $this->getAppliesTo() === CapacityAssignmentAppliesTo::PRODUCTS->name,
value: [
'products' => $this->getProducts()?->map(fn (ProductDomainObject $product) => [
'id' => $product->getId(),
'title' => $product->getTitle(),
]),
]),
];
}
}