adrema/app/Member/Actions/MemberShowAction.php

41 lines
1.0 KiB
PHP
Raw Normal View History

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 [
'data' => new MemberResource($member
->load('memberships')
2022-12-13 23:11:32 +01:00
->load('payments.subscription.children')
->load('nationality')
->load('region')
2022-11-22 00:37:34 +01:00
->load('subscription')
->load('courses.course')
),
2022-11-18 15:55:44 +01:00
'toolbar' => [['href' => route('member.index'), 'label' => 'Zurück', 'color' => 'primary', 'icon' => 'undo']],
];
}
public function asController(Member $member): Response
{
session()->put('menu', 'member');
session()->put('title', 'Mitglied '.$member->fullname);
return Inertia::render('member/ShowView', $this->handle($member));
2022-11-18 15:55:44 +01:00
}
}