public function store() { $first_name = Input::get('first_name'); $last_name = Input::get('last_name'); $email = Input::get('email'); $image = Input::file('photo'); $input_data = Input::all(); $employees = new Employees(); //validation check $validator = Validator::make(Input::all(), $this->registration_form_rules); // check if the validator failed ----------------------- if (!$validator->fails()) { $employees->first_name = $first_name; $employees->last_name = $last_name; $employees->email = $email; $img_dir = "images/employees/" . date("h-m-y"); if (!file_exists($img_dir)) { mkdir($img_dir, 0777, true); } $filename = $image->getClientOriginalName(); $pathL = public_path($img_dir . "-" . $filename); Image::make($image->getRealPath())->resize(900, 600)->save($pathL); $employees->photo = $img_dir . "-" . $filename; //insert data if ($employees->save()) { Session::flash('success', 'Successfully added'); return Redirect::to('/'); } else { Session::flash('success', 'Something Wrong'); return Redirect::to('employees/create'); } } else { $messages = $validator->messages(); return Redirect::to('employees/create')->withErrors($validator); } }