Files
mareike/app/Resources/EventParticipantAddonResource.php
T
2026-08-12 16:45:02 +02:00

27 lines
744 B
PHP

<?php
namespace App\Resources;
use App\Models\EventParticipantAddon;
use Illuminate\Http\Resources\Json\JsonResource;
class EventParticipantAddonResource extends JsonResource
{
function __construct(EventParticipantAddon $addon)
{
parent::__construct($addon);
}
public function toArray($request): array
{
return [
'addonKey' => $this->resource->addon_key,
'title' => $this->resource->title,
'flat' => $this->resource->flat,
'amount' => $this->resource->amount?->getAmount() ?? 0,
'amountReadable' => $this->resource->amount?->toString() ?? '0,00 Euro',
'free' => ($this->resource->amount?->getAmount() ?? 0) <= 0,
];
}
}