Files
mareike/app/Resources/ParticipantRefundResource.php
T

38 lines
1.3 KiB
PHP

<?php
namespace App\Resources;
use App\Models\ParticipantRefund;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* Der Erstattungsvorgang für das Frontend.
*
* Bewusst NICHT `$this->resource->toArray()` als Basis wie in {@see EventParticipantResource}: die
* Bankverbindung darf nur dorthin, wo sie hingehört (Beleg und Auszahlung), nicht in jede
* Teilnehmerliste. Deshalb werden die Felder hier einzeln aufgeführt.
*/
class ParticipantRefundResource extends JsonResource
{
public function __construct(ParticipantRefund $refund)
{
parent::__construct($refund);
}
public function toArray($request): array
{
return [
'token' => $this->resource->token,
'status' => $this->resource->status,
'amount' => $this->resource->amount?->toString() ?? '0,00 Euro',
'amountValue' => $this->resource->amount?->getAmount() ?? 0.0,
'reason' => $this->resource->reason,
'reasonLabel' => $this->resource->reasonLabel(),
'reasonNote' => $this->resource->reason_note,
'releasedAt' => $this->resource->released_at?->format('d.m.Y'),
'acceptedAt' => $this->resource->accepted_at?->format('d.m.Y'),
'cancelledAt' => $this->resource->cancelled_at?->format('d.m.Y'),
];
}
}