adrema/app/Member/MemberResource.php

67 lines
2.6 KiB
PHP
Raw Normal View History

2020-06-02 23:45:25 +02:00
<?php
namespace App\Member;
2021-11-19 22:58:27 +01:00
use App\Course\Resources\CourseResource;
2021-08-22 22:23:17 +02:00
use App\Membership\MembershipResource;
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
2022-01-02 12:32:57 +01:00
/**
* @mixin \App\Member\Member
*/
2020-06-02 23:45:25 +02:00
class MemberResource extends JsonResource
{
/**
* Transform the resource into an array.
*
2022-03-11 20:19:17 +01:00
* @param \Illuminate\Http\Request $request
*
2020-06-02 23:45:25 +02:00
* @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,
2022-03-11 20:19:17 +01:00
'has_nami' => null !== $this->nami_id,
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-08-22 22:23:17 +02:00
'memberships' => MembershipResource::collection($this->whenLoaded('memberships')),
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-08-22 19:31:20 +02:00
'age_group_icon' => $this->age_group_icon,
2021-11-19 22:58:27 +01:00
'courses' => CourseResource::collection($this->whenLoaded('courses')),
2021-04-11 02:55:26 +02:00
];
2020-06-02 23:45:25 +02:00
}
}