public function EditProduct($id) { $title = $_POST["productTitle"]; $description = $_POST["productDescription"]; $price = $_POST["productPrice"]; $hasModels = $_POST["productHasModels"]; $category = $_POST["productCategory"]; $subcategory = $_POST["subCategorySelect"]; if (Input::hasFile("product_picture")) { $has_file = true; $file = Input::file("product_picture"); $folder = '/images/'; $destinationPath = public_path() . $folder; $filename = str_random(6) . '_' . $file->getClientOriginalName(); $img_path = $folder . $filename; $uploadSuccess = $file->move($destinationPath, $filename); $pd = Product::GetProductByID($id); $img = $pd[0]->product_image; if (File::exists(public_path() . $img)) { File::delete(public_path() . $img); } } else { $has_file = false; $pd = Product::GetProductByID($id); $img = $pd[0]->product_image; $img_path = $img; } Product::EditProduct($id, $title, $description, $price, $category, $subcategory, $img_path, $hasModels); return Redirect::to("admin/edit_product/" . $id); }