File::delete($filename); } $urlNew = $destinationUpdate["new"]["logo"]; $requestNew = Request::create($urlNew); $nameNew = $requestNew->segments(); $nameNew = $nameNew[count($nameNew) - 1]; $fileNew = file_get_contents($urlNew); $destination = Destination::where("Dest_Name", '=', $destinationUpdate["old"]["namadestinasi"])->where("Dest_Email", '=', $destinationUpdate["old"]["email"]); $destinationNew = ["Dest_Name" => $destinationUpdate["new"]["namadestinasi"], "Dest_Picture" => $nameNew, "Dest_Description" => $destinationUpdate["new"]["description"], "Dest_Telp" => $destinationUpdate["new"]["telephone"], "Dest_Email" => $destinationUpdate["new"]["email"], "Latitude" => $destinationUpdate["new"]["latitude"], "Longitude" => $destinationUpdate["new"]["longitude"], "Web_Link" => $destinationUpdate["new"]["linkweb"], "Status" => "Active"]; if ($destination->count() == 1) { file_put_contents("resources/images/destination/" . $nameNew, $fileNew); $destination->update($destinationNew); } else { if ($destination->count() == 0) { file_put_contents("resources/images/destination/" . $nameNew, $fileNew); Destination::create($destinationNew); } } }); Route::POST('/DeleteDestinasi', function () { //$getDestinasi = Input::json()->all(); $file = fopen("delete_dest.txt", "w+"); fwrite($file, print_r(Input::json()->all()[0], true)); fclose($file); $getDestinasi = json_decode(Input::json()->all()[0], true)['destinasi']; $dest = ["Dest_Name" => $getDestinasi["namadestinasi"], "Dest_Picture" => $getDestinasi["logo"], "Dest_Description" => $getDestinasi["description"], "Dest_Telp" => $getDestinasi["telephone"], "Dest_Email" => $getDestinasi["email"], "Latitude" => $getDestinasi["latitude"], "Longitude" => $getDestinasi["longitude"], "Web_Link" => $getDestinasi["linkweb"]]; $destination = Destination::where("Dest_Name", "=", $dest['Dest_Name'])->where("Dest_Email", "=", $dest['Dest_Email']); if ($destination->count() == 1) { //Destination::where("Event_ID",'=',$destination->get(["Event_ID"])->first()->Event_ID)->delete(); $destination->delete(); }