34 lines
890 B
PHP
34 lines
890 B
PHP
<?php
|
|
|
|
namespace App\Resources;
|
|
|
|
use App\Models\EventParticipant;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class EventParticipantResource extends JsonResource
|
|
{
|
|
function __construct(EventParticipant $participant)
|
|
{
|
|
parent::__construct($participant);
|
|
}
|
|
|
|
public function toArray($request) : array
|
|
{
|
|
$event = $this->resource->event;
|
|
|
|
|
|
|
|
return array_merge(
|
|
$this->resource->toArray(),
|
|
[
|
|
'needs_payment' => $this->resource->amount->getAmount() > 0 && $event->pay_direct,
|
|
'nicename' => $this->resource->getNicename(),
|
|
'arrival' => $this->resource->arrival_date->format('d.m.Y'),
|
|
'departure' => $this->resource->departure_date->format('d.m.Y'),
|
|
'amount_left_string' => $this->resource->amount->toString(),
|
|
]
|
|
|
|
);
|
|
}
|
|
}
|