diff --git a/app/Member/MemberController.php b/app/Member/MemberController.php index 9d2b1599..adc040e4 100644 --- a/app/Member/MemberController.php +++ b/app/Member/MemberController.php @@ -14,6 +14,7 @@ use App\Bill\BillKind; class MemberController extends Controller { + public function index(Request $request) { session()->put('menu', 'member'); session()->put('title', 'Mitglieder'); @@ -39,8 +40,8 @@ class MemberController extends Controller ]); } - public function update(Member $member, Request $request) { - $member->update($request->input()); + public function update(Member $member, MemberRequest $request) { + $request->persistUpdate($member); return redirect()->route('member.index'); } diff --git a/app/Member/MemberRequest.php b/app/Member/MemberRequest.php new file mode 100644 index 00000000..2ac1c1a4 --- /dev/null +++ b/app/Member/MemberRequest.php @@ -0,0 +1,51 @@ +<?php + +namespace App\Member; + +use Illuminate\Foundation\Http\FormRequest; + +class MemberRequest extends FormRequest +{ + /** + * Determine if the user is authorized to make this request. + * + * @return bool + */ + public function authorize() + { + return true; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return [ + 'firstname' => 'required', + 'lastname' => 'required', + 'address' => 'required', + 'zip' => 'required|numeric', + 'location' => 'required', + 'birthday' => 'date|required', + 'region_id' => 'nullable|exists:regions,id', + 'country_id' => 'required|exists:countries,id', + 'nationality_id' => 'required|exists:nationalities,id', + 'email' => 'nullable|email', + 'email_parents' => 'nullable|email', + 'bill_kind_id' => 'nullable|exists:bill_kinds,id', + 'joined_at' => 'date|required', + 'confession_id' => 'nullable|exists:confessions,id', + ]; + } + + public function persistCreate() { + + } + + public function persistUpdate(Member $member) { + $member->update($this->input()); + } +}