2022-11-18 15:55:44 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Member\Actions;
|
|
|
|
|
|
|
|
use App\Member\Member;
|
|
|
|
use App\Member\MemberResource;
|
|
|
|
use Inertia\Inertia;
|
|
|
|
use Inertia\Response;
|
|
|
|
use Lorisleiva\Actions\Concerns\AsAction;
|
|
|
|
|
|
|
|
class MemberShowAction
|
|
|
|
{
|
|
|
|
use AsAction;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array{data: MemberResource}
|
|
|
|
*/
|
|
|
|
public function handle(Member $member): array
|
|
|
|
{
|
|
|
|
return [
|
2023-12-19 02:00:42 +01:00
|
|
|
'data' => new MemberResource(
|
|
|
|
$member
|
|
|
|
->load('memberships')
|
|
|
|
->load('invoicePositions.invoice')
|
|
|
|
->load('nationality')
|
|
|
|
->load('region')
|
|
|
|
->load('subscription')
|
|
|
|
->load('courses.course')
|
2022-11-19 00:09:53 +01:00
|
|
|
),
|
2023-05-02 23:13:00 +02:00
|
|
|
'meta' => MemberResource::meta(),
|
2022-11-18 15:55:44 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function asController(Member $member): Response
|
|
|
|
{
|
|
|
|
session()->put('menu', 'member');
|
2023-12-19 02:00:42 +01:00
|
|
|
session()->put('title', 'Mitglied ' . $member->fullname);
|
2022-11-18 15:55:44 +01:00
|
|
|
|
2022-11-19 00:09:53 +01:00
|
|
|
return Inertia::render('member/ShowView', $this->handle($member));
|
2022-11-18 15:55:44 +01:00
|
|
|
}
|
|
|
|
}
|