/** * Show the form for creating a new resource. * * @return Response */ public function create(Request $request) { if ($request->isMethod('post')) { $validator = Validator::make($request->all(), ['first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email|unique:suppliers', 'password' => 'required']); if ($validator->fails()) { return redirect::route('add_supplier')->with('errmsg', [$validator->messages()->all()]); } else { $first_name = $request->first_name; $last_name = $request->last_name; $phone = $request->phone; $password = $request->password; $email = $request->email; $password = $request->password; $insert_arr = array('first_name' => $first_name, 'last_name' => $last_name, 'phone' => $phone, 'email' => $email, 'password' => Hash::make($password)); Supplier::insert($insert_arr); return redirect::route('add_supplier')->with('successmsg', 'Supplier is added successfully'); } } return view('supplier/create_supplier'); }