Additional event informations can be added
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Resources;
|
||||
|
||||
use App\Models\EventParticipantOption;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class EventParticipantOptionResource extends JsonResource
|
||||
{
|
||||
function __construct(EventParticipantOption $option)
|
||||
{
|
||||
parent::__construct($option);
|
||||
}
|
||||
|
||||
public function toArray($request): array
|
||||
{
|
||||
return [
|
||||
'questionKey' => $this->resource->question_key,
|
||||
'questionLabel' => $this->resource->question_label,
|
||||
'value' => $this->resource->value,
|
||||
'valueLabel' => $this->resource->value_label,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -96,6 +96,8 @@ class EventParticipantResource extends JsonResource
|
||||
'eventName' => $this->resource->event()->first()->name,
|
||||
'arrivalDateReadable' => $this->resource->arrival_date->format('d.m.Y'),
|
||||
'departureDateReadable' => $this->resource->departure_date->format('d.m.Y'),
|
||||
'participationOptions' => $this->resource->selectedOptions()->get()->map(
|
||||
fn($option) => new EventParticipantOptionResource($option)->toArray($request))->toArray(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -138,6 +138,9 @@ class EventResource extends JsonResource{
|
||||
$returnArray['paymentMethods'] = $this->event->paymentMethods()->get()->map(
|
||||
fn($paymentMethod) => new AvailablePaymentMethodResource($paymentMethod)->toArray($request))->toArray();
|
||||
|
||||
// Veranstaltungsspezifische Pflicht-Auswahlfragen (Teilnahmeoptionen); leeres Array => Schritt entfällt.
|
||||
$returnArray['participationOptions'] = $this->event->participation_options ?? [];
|
||||
|
||||
|
||||
$returnArray['participationTypes'] = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user