From 4ba63d63914a4078c000ef1145eeef288b79a2ff Mon Sep 17 00:00:00 2001 From: Philipp Lang Date: Mon, 5 Jul 2021 13:31:20 +0200 Subject: [PATCH] fixed: set first activity id on update --- app/Member/MemberController.php | 6 ++++++ app/Member/MemberRequest.php | 2 +- app/Member/MemberResource.php | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Member/MemberController.php b/app/Member/MemberController.php index 9746881b..8a683236 100644 --- a/app/Member/MemberController.php +++ b/app/Member/MemberController.php @@ -67,7 +67,13 @@ class MemberController extends Controller session()->put('menu', 'member'); session()->put('title', "Mitglied {$member->firstname} {$member->lastname} bearbeiten"); + $activities = Activity::with('subactivities')->get(); + return \Inertia::render('member/Form', [ + '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::get()->pluck('name', 'id'), 'genders' => Gender::get()->pluck('name', 'id'), 'countries' => Country::get()->pluck('name', 'id'), diff --git a/app/Member/MemberRequest.php b/app/Member/MemberRequest.php index 99d938de..98ef7afd 100644 --- a/app/Member/MemberRequest.php +++ b/app/Member/MemberRequest.php @@ -66,7 +66,7 @@ class MemberRequest extends FormRequest } public function persistUpdate(Member $member) { - $member->update(Arr::except($this->input(), ['first_activity_id', 'first_subactivity_id'])); + $member->update($this->input()); if($this->input('has_nami') && $member->nami_id === null) { CreateJob::dispatch($member, auth()->user()); diff --git a/app/Member/MemberResource.php b/app/Member/MemberResource.php index 03fa409d..ec796be7 100644 --- a/app/Member/MemberResource.php +++ b/app/Member/MemberResource.php @@ -50,6 +50,8 @@ class MemberResource extends JsonResource 'children_phone' => $this->children_phone, 'payments' => PaymentResource::collection($this->whenLoaded('payments')), 'pending_payment' => $this->pending_payment ? number_format($this->pending_payment / 100, 2, ',', '.').' €' : null, + 'first_activity_id' => $this->first_activity_id, + 'first_subactivity_id' => $this->first_subactivity_id, ]; } }