diff --git a/app/Member/MemberController.php b/app/Member/MemberController.php index 83c38763..83b0b6f4 100644 --- a/app/Member/MemberController.php +++ b/app/Member/MemberController.php @@ -25,11 +25,11 @@ class MemberController extends Controller ]); } - public function edit(Member $member, Request $request) { + public function create() { session()->put('menu', 'member'); - session()->put('title', 'Mitglied bearbeiten'); + session()->put('title', 'Mitglied erstellen'); - return \Inertia::render('member/Edit', [ + return \Inertia::render('member/Form', [ 'billKinds' => BillKind::get()->pluck('name', 'id'), 'genders' => Gender::get()->pluck('name', 'id'), 'countries' => Country::get()->pluck('name', 'id'), @@ -37,7 +37,31 @@ class MemberController extends Controller 'nationalities' => Nationality::get()->pluck('name', 'id'), 'confessions' => Confession::where('is_null', false)->get()->pluck('name', 'id'), 'fees' => Fee::get()->pluck('name', 'id'), - 'data' => new MemberResource($member) + 'data' => null, + 'mode' => 'create', + ]); + } + + public function store(MemberRequest $request) { + $request->persistCreate(); + + return redirect()->route('member.index'); + } + + public function edit(Member $member, Request $request) { + session()->put('menu', 'member'); + session()->put('title', 'Mitglied bearbeiten'); + + return \Inertia::render('member/Form', [ + 'billKinds' => BillKind::get()->pluck('name', 'id'), + 'genders' => Gender::get()->pluck('name', 'id'), + 'countries' => Country::get()->pluck('name', 'id'), + 'regions' => Region::where('is_null', false)->get()->pluck('name', 'id'), + 'nationalities' => Nationality::get()->pluck('name', 'id'), + 'confessions' => Confession::where('is_null', false)->get()->pluck('name', 'id'), + 'fees' => Fee::get()->pluck('name', 'id'), + 'data' => new MemberResource($member), + 'mode' => 'edit', ]); } diff --git a/app/Member/MemberRequest.php b/app/Member/MemberRequest.php index 2ac1c1a4..33df5212 100644 --- a/app/Member/MemberRequest.php +++ b/app/Member/MemberRequest.php @@ -42,7 +42,7 @@ class MemberRequest extends FormRequest } public function persistCreate() { - + Member::create($this->input()); } public function persistUpdate(Member $member) { diff --git a/resources/js/views/member/Edit.vue b/resources/js/views/member/Edit.vue deleted file mode 100644 index 217cbfc1..00000000 --- a/resources/js/views/member/Edit.vue +++ /dev/null @@ -1,128 +0,0 @@ - - - diff --git a/resources/js/views/member/Form.vue b/resources/js/views/member/Form.vue new file mode 100644 index 00000000..884ccc58 --- /dev/null +++ b/resources/js/views/member/Form.vue @@ -0,0 +1,99 @@ + + +