adrema/app/Member/MemberResource.php

58 lines
2.3 KiB
PHP
Raw Normal View History

2020-06-02 23:45:25 +02:00
<?php
namespace App\Member;
2021-07-04 16:56:07 +02:00
use App\Payment\PaymentResource;
2021-07-17 16:57:37 +02:00
use Illuminate\Http\Resources\Json\JsonResource;
2020-06-02 23:45:25 +02:00
class MemberResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
2021-04-11 02:55:26 +02:00
return [
'firstname' => $this->firstname,
'lastname' => $this->lastname,
'address' => $this->address,
'zip' => $this->zip,
'location' => $this->location,
'send_newspaper' => $this->send_newspaper,
2021-04-11 17:13:56 +02:00
'birthday' => $this->birthday->format('Y-m-d'),
'birthday_human' => $this->birthday->format('d.m.Y'),
2021-04-11 17:18:28 +02:00
'joined_at' => $this->joined_at->format('Y-m-d'),
'joined_at_human' => $this->joined_at->format('d.m.Y'),
2021-04-11 11:19:55 +02:00
'id' => $this->id,
2021-07-04 12:09:30 +02:00
'subscription_id' => $this->subscription_id,
2021-07-04 18:29:21 +02:00
'subscription_name' => $this->subscription_name,
2021-04-11 11:19:55 +02:00
'gender_id' => $this->gender_id,
'further_address' => $this->further_address,
'work_phone' => $this->work_phone,
'mobile_phone' => $this->mobile_phone,
'main_phone' => $this->main_phone,
'email' => $this->email,
'email_parents' => $this->email_parents,
'fax' => $this->fax,
2021-04-11 11:44:51 +02:00
'country_id' => $this->country_id,
'region_id' => $this->region_id,
'nationality_id' => $this->nationality_id,
'other_country' => $this->other_country,
'confession_id' => $this->confession_id,
2021-04-11 17:37:26 +02:00
'letter_address' => $this->letter_address,
2021-04-11 18:17:40 +02:00
'bill_kind_id' => $this->bill_kind_id,
'bill_kind_name' => optional($this->billKind)->name,
2021-04-11 20:35:18 +02:00
'has_nami' => $this->nami_id !== null,
2021-06-28 22:09:41 +02:00
'is_confirmed' => $this->is_confirmed,
2021-06-28 22:55:55 +02:00
'children_phone' => $this->children_phone,
2021-07-04 16:56:07 +02:00
'payments' => PaymentResource::collection($this->whenLoaded('payments')),
2021-07-04 21:47:20 +02:00
'pending_payment' => $this->pending_payment ? number_format($this->pending_payment / 100, 2, ',', '.').' €' : null,
2021-07-05 13:31:20 +02:00
'first_activity_id' => $this->first_activity_id,
'first_subactivity_id' => $this->first_subactivity_id,
2021-04-11 02:55:26 +02:00
];
2020-06-02 23:45:25 +02:00
}
}