public function edit_post($id) { $valid = Validator::make(Input::all(), Food::rule_edit_food($id), Food::$food_langs); if ($valid->passes()) { $data = Input::all(); $img = $data['food_image']; $isUpload = $img->move("uploads/food/"); if ($isUpload) { $data = array("food_name" => Input::get("food_name"), "food_price" => Input::get("food_price"), "food_description" => Input::get("food_description"), "food_image" => $img->getClientOriginalName(), "food_created_at" => date("Y-m-d")); DB::table("foods")->where("food_id", $id)->update($data); return Redirect::route("manage_food")->with("flash_success", "Chúc mừng bạn đã sửa món ăn thành công"); } return Redirect::route("manage_food")->with("flash_error", "Không thể upload ảnh"); } return Redirect::route("manage_food_edit_get", $id)->withInput()->with("flash_error", $valid->errors()->first()); }