v0.10.0b - Fixed Location update AJAX

Added - You are now able to delete a location
This commit is contained in:
Anders
2020-08-17 10:43:52 +02:00
parent 773655c294
commit 3bde377caa
4 changed files with 68 additions and 9 deletions
@@ -61,7 +61,7 @@ class LocationController extends Controller
// If there already is a washing machine with that name, then don't add it
if (count($locations) > 0)
return redirect()->route("locations.store")->with('NameExists', '<p><b>Der findes allerede en lokation med det navn!</b></p>');
return redirect()->route("locations.index");
else { // Else - Add it
$location->save();
$locations = Location::query()->paginate($request->input("limit", 20));
@@ -111,7 +111,7 @@ class LocationController extends Controller
// If there already is a washing machine with that name, then don't change it
if (count($allMachines) > 0)
return redirect()->route("locations.store")->with('NameExists', '<p><b>Der findes allerede en lokation med det navn!</b></p>');
return redirect()->route("locations.index");
else { // Else - Change the name
$location->update($data);
$location->save();
@@ -124,12 +124,15 @@ class LocationController extends Controller
/**
* Remove the specified resource from storage.
*
* @param \App\Location $location
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy(Location $location)
public function destroy($id)
{
$locations = Location::find($id);
$locations->delete();
return redirect()->route("locations.index");
}
public function nameCheck(Request $request){
@@ -139,4 +142,10 @@ class LocationController extends Controller
}
}
public function nameCheckUpdate(Request $request){
$locations = Location::query()->where('name', 'LIKE',$request->nameCheck)->where('id', '!=', $request->id)->get();
if(count($locations) > 0 && $request->nameCheck !== NULL){
return 1;
}
}
}