user()->api()->group($member->group->nami_id)->member($member->nami_id) ->putMembership([ 'starts_at' => now(), 'group_id' => $member->group->nami_id, 'activity_id' => Activity::find($request->input('activity_id'))->nami_id, 'subactivity_id' => optional(Subactivity::find($request->input('subactivity_id')))->nami_id, ]); $member->memberships()->create(array_merge( $request->input(), ['nami_id' => $namiId], )); $member->syncVersion(auth()->user()->api()); return redirect()->back(); } public function destroy(Member $member, Membership $membership): RedirectResponse { auth()->user()->api()->group($member->group->nami_id)->member($member->nami_id) ->deleteMembership($membership->nami_id); $membership->delete(); $member->syncVersion(auth()->user()->api()); return redirect()->back(); } }