public function postAddStore() { $inputData = Input::all(); $formData = array('store_name' => $inputData['store_name'], 'store_image' => $inputData['store_image'], 'store_slug' => $inputData['store_slug']); $rules = array('store_name' => 'required|unique:stores', 'store_image' => 'required|image', 'store_slug' => 'required|unique:stores'); $validator = Validator::make($formData, $rules); if ($validator->fails()) { $validation = $validator->getMessageBag()->toArray(); foreach ($validation as $k => $v) { $val[$k] = $v; } return Redirect::to('admin/add-store')->with('error', $val)->withInput(); } else { //hash it now $file = $formData['store_image']; $destinationPath = public_path() . '/uploads/images/store'; $filename = $file->getClientOriginalName(); $extension = $file->getClientOriginalExtension(); $final_img = $filename; $upload_success = $file->move($destinationPath, $final_img); $img = Image::make($destinationPath . '/' . $final_img); $img->resize(300, 150); $img->save($destinationPath . '/' . $final_img); $formData['store_image'] = $final_img; if (Stores::create($formData)) { return Redirect::to('admin/add-store')->with('success', 'Store has been Successfuly added'); } } }