Basic implementation of payment methods
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Resources;
|
||||
|
||||
use App\Models\AvailablePaymentMethod;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AvailablePaymentMethodResource extends JsonResource {
|
||||
private AvailablePaymentMethod $availablePaymentMethod;
|
||||
|
||||
public function __construct(AvailablePaymentMethod $availablePaymentMethod) {
|
||||
$this->availablePaymentMethod = $availablePaymentMethod;
|
||||
}
|
||||
|
||||
public function toArray($request) : array {
|
||||
return [
|
||||
'id' => $this->availablePaymentMethod->id,
|
||||
'slug' => $this->availablePaymentMethod->slug,
|
||||
'name' => $this->availablePaymentMethod->name,
|
||||
'description' => $this->availablePaymentMethod->description,
|
||||
'active' => $this->availablePaymentMethod->active,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,9 @@ namespace App\Resources;
|
||||
use App\Enumerations\EatingHabit;
|
||||
use App\Enumerations\EfzStatus;
|
||||
use App\Enumerations\ParticipationType;
|
||||
use App\Models\AvailablePaymentMethod;
|
||||
use App\Models\EventParticipant;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\ValueObjects\Age;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
@@ -52,7 +54,9 @@ class EventParticipantResource extends JsonResource
|
||||
'tetanusVaccinationEdit' => $this->resource->tetanus_vaccination?->format('Y-m-d') ?? null,
|
||||
'presenceDays' => ['real' => $presenceDays, 'support' => $presenceDaysSupport],
|
||||
'participationType' => ParticipationType::where(['slug' => $this->resource->participation_type])->first()->name,
|
||||
'needs_payment' => $this->resource->amount->getAmount() > 0 && $event->pay_direct && $this->resource->amount_paid?->getAmount() < $this->resource->amount->getAmount(),
|
||||
'needs_payment' => $this->resource->amount->getAmount() > 0
|
||||
&& $this->resource->payment_method === PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION
|
||||
&& $this->resource->amount_paid?->getAmount() < $this->resource->amount->getAmount(),
|
||||
'nicename' => $this->resource->getNicename(),
|
||||
'arrival' => $this->resource->arrival_date->format('d.m.Y'),
|
||||
'departure' => $this->resource->departure_date->format('d.m.Y'),
|
||||
@@ -68,6 +72,9 @@ class EventParticipantResource extends JsonResource
|
||||
'localGroupState' => null !== $this->resource->localGroup()->first()?->postcode ? config('postCode.map.' . $this->resource->postcode) : '--',
|
||||
'birthday' => $this->resource->birthday->format('d.m.Y'),
|
||||
'eatingHabit' => EatingHabit::where('slug', $this->resource->eating_habit)->first()->name,
|
||||
'paymentMethod' => $this->resource->payment_method !== null
|
||||
? AvailablePaymentMethod::withoutGlobalScopes()->where('tenant', $this->resource->tenant)->where('slug', $this->resource->payment_method)->first()?->name ?? $this->resource->payment_method
|
||||
: null,
|
||||
'cocColor' => match ($this->resource->efz_status) {
|
||||
EfzStatus::EFZ_STATUS_CHECKED_VALID => 'bg-green',
|
||||
EfzStatus::EFZ_STATUS_NOT_REQUIRED => 'bg-green',
|
||||
|
||||
@@ -134,6 +134,9 @@ class EventResource extends JsonResource{
|
||||
$returnArray['eatingHabits'] = $this->event->eatingHabits()->get()->map(
|
||||
fn($eatingHabit) => new EatingHabitResource($eatingHabit))->toArray();
|
||||
|
||||
$returnArray['paymentMethods'] = $this->event->paymentMethods()->get()->map(
|
||||
fn($paymentMethod) => new AvailablePaymentMethodResource($paymentMethod))->toArray();
|
||||
|
||||
|
||||
$returnArray['participationTypes'] = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user