put('menu', 'member'); session()->put('title', 'Mitglieder'); $payload = app(MemberView::class)->index($request); $payload['billKinds'] = BillKind::forSelect(); return \Inertia::render('member/VIndex', $payload); } public function create(): Response { session()->put('menu', 'member'); session()->put('title', 'Mitglied erstellen'); $activities = Activity::remote()->with(['subactivities' => fn ($q) => $q->remote()])->get(); return \Inertia::render('member/VForm', [ 'activities' => $activities->pluck('name', 'id'), 'subactivities' => $activities->map(function (Activity $activity) { return ['subactivities' => $activity->subactivities()->pluck('name', 'id'), 'id' => $activity->id]; })->pluck('subactivities', 'id'), 'billKinds' => BillKind::forSelect(), 'genders' => Gender::pluck('name', 'id'), 'countries' => Country::pluck('name', 'id'), 'regions' => Region::where('is_null', false)->pluck('name', 'id'), 'nationalities' => Nationality::pluck('name', 'id'), 'confessions' => Confession::where('is_null', false)->pluck('name', 'id'), 'subscriptions' => Subscription::pluck('name', 'id'), 'data' => [ 'country_id' => Country::default(), 'efz' => null, 'ps_at' => null, 'without_education_at' => null, 'without_efz_at' => null, 'more_ps_at' => null, ], 'mode' => 'create', 'meta' => MemberResource::meta(), ]); } public function store(MemberRequest $request, NamiSettings $settings): RedirectResponse { $request->persistCreate($settings); return redirect()->route('member.index'); } public function edit(Member $member, Request $request): Response { session()->put('menu', 'member'); session()->put('title', "Mitglied {$member->firstname} {$member->lastname} bearbeiten"); $activities = Activity::remote()->with(['subactivities' => fn ($q) => $q->remote()])->get(); return \Inertia::render('member/VForm', [ 'activities' => $activities->pluck('name', 'id'), 'subactivities' => $activities->map(function ($activity) { return ['subactivities' => $activity->subactivities->pluck('name', 'id'), 'id' => $activity->id]; })->pluck('subactivities', 'id'), 'billKinds' => BillKind::forSelect(), 'genders' => Gender::pluck('name', 'id'), 'countries' => Country::pluck('name', 'id'), 'regions' => Region::where('is_null', false)->pluck('name', 'id'), 'nationalities' => Nationality::pluck('name', 'id'), 'confessions' => Confession::where('is_null', false)->pluck('name', 'id'), 'subscriptions' => Subscription::select('name', 'id')->get(), 'data' => new MemberResource($member), 'mode' => 'edit', 'conflict' => '1' === $request->query('conflict', '0'), 'meta' => MemberResource::meta(), ]); } public function update(Member $member, MemberRequest $request): RedirectResponse { try { $request->persistUpdate($member); } catch (ConflictException $e) { return redirect()->route('member.edit', ['member' => $member, 'conflict' => '1']); } return redirect()->route('member.index'); } public function destroy(Member $member): RedirectResponse { if ($member->nami_id) { DeleteJob::dispatch($member->nami_id); } $member->delete(); return redirect()->back(); } }