Basic signup for events
This commit is contained in:
34
app/Resources/ParticipationFeeTypeResource.php
Normal file
34
app/Resources/ParticipationFeeTypeResource.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Resources;
|
||||
|
||||
use App\RelationModels\EventParticipationFee;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ParticipationFeeTypeResource extends JsonResource
|
||||
{
|
||||
public function __construct(private EventParticipationFee $participationFee) {}
|
||||
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$return = [
|
||||
'type' => new ParticipationTypeResource($this->participationFee->type()->first())->toArray($request),
|
||||
'name' => $this->participationFee->name,
|
||||
'description' => $this->participationFee->description,
|
||||
'amount_standard' => ['internal' => $this->participationFee->amount_standard, 'readable' => $this->participationFee->amount_standard->toString()],
|
||||
'amount_reduced' => ['internal' => null, 'readable' => null],
|
||||
'amount_solidarity' => ['internal' => null, 'readable' => null],
|
||||
];
|
||||
|
||||
if ($this->participationFee->amount_reduced !== null) {
|
||||
$return['amount_reduced'] = ['internal' => $this->participationFee->amount_reduced, 'readable' => $this->participationFee->amount_reduced->toString()];
|
||||
}
|
||||
|
||||
if ($this->participationFee->amount_solidarity !== null) {
|
||||
$return['amount_solidarity'] = ['internal' => $this->participationFee->amount_solidarity, 'readable' => $this->participationFee->amount_solidarity->toString()];
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user