2021-07-04 16:56:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Payment;
|
|
|
|
|
2023-10-13 15:48:29 +02:00
|
|
|
use App\Member\Member;
|
2021-07-04 16:56:07 +02:00
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
|
2022-01-02 12:32:57 +01:00
|
|
|
/**
|
|
|
|
* @mixin Payment
|
|
|
|
*/
|
2021-07-04 16:56:07 +02:00
|
|
|
class PaymentResource extends JsonResource
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Transform the resource into an array.
|
|
|
|
*
|
2022-03-11 20:19:17 +01:00
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
*
|
2021-07-04 16:56:07 +02:00
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function toArray($request)
|
|
|
|
{
|
|
|
|
return [
|
2022-11-18 22:41:40 +01:00
|
|
|
'subscription_id' => $this->subscription_id,
|
2022-11-18 22:34:50 +01:00
|
|
|
'subscription' => new SubscriptionResource($this->whenLoaded('subscription')),
|
2021-07-04 16:56:07 +02:00
|
|
|
'status_name' => $this->status->name,
|
|
|
|
'status_id' => $this->status->id,
|
|
|
|
'nr' => $this->nr,
|
|
|
|
'id' => $this->id,
|
2021-07-04 17:03:56 +02:00
|
|
|
'is_accepted' => $this->status->isAccepted(),
|
2023-10-13 15:48:29 +02:00
|
|
|
'links' => [
|
2023-12-01 01:25:02 +01:00
|
|
|
'show' => $this->invoice_data
|
|
|
|
? route('payment.pdf', ['payment' => $this->getModel()])
|
|
|
|
: null,
|
2023-10-16 16:21:23 +02:00
|
|
|
'update' => route('payment.update', ['payment' => $this->getModel()]),
|
|
|
|
'destroy' => route('payment.destroy', ['payment' => $this->getModel()]),
|
2023-10-13 15:48:29 +02:00
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array<string, mixed>
|
|
|
|
*/
|
|
|
|
public static function memberMeta(Member $member): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'statuses' => Status::forSelect(),
|
|
|
|
'subscriptions' => Subscription::forSelect(),
|
|
|
|
'default' => [
|
|
|
|
'nr' => '',
|
|
|
|
'subscription_id' => null,
|
|
|
|
'status_id' => null
|
|
|
|
],
|
|
|
|
'links' => [
|
|
|
|
'store' => route('member.payment.store', ['member' => $member]),
|
|
|
|
]
|
2021-07-04 16:56:07 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|