rules = [ 'father' => [ 'max:255'], 'mother' => [ 'max:255'], 'sibling' => [ 'max:255'], ]; $this->messages = [ 'father.max' => translate('Max 255 characters'), 'mother.max' => translate('Max 255 characters'), 'sibling.max' => translate('Max 255 characters'), ]; $rules = $this->rules; $messages = $this->messages; $validator = Validator::make($request->all(), $rules, $messages); if ($validator->fails()) { flash(translate('Something went wrong'))->error(); return Redirect::back()->withErrors($validator); } $family = Family::where('user_id', $id)->first(); if(empty($family)){ $family = new Family; $family->user_id = $id; } $family->father = $request->father; $family->mother = $request->mother; $family->sibling = $request->sibling; if($family->save()){ flash(translate('Family info has been updated successfully'))->success(); return back(); } else { flash(translate('Sorry! Something went wrong.'))->error(); return back(); } } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // } }