Merge branch 'master' of https://github.com/sebathefox/skolehjem-webapp into master
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class WashingMachineController extends Controller
|
||||
|
||||
// If there already is a washing machine with that name, then don't add it
|
||||
if (count($allMachines) > 0)
|
||||
return redirect()->route("washing-machines.store")->with('WashingNameExists', '<p><b>Der findes allerede en vaskemaskine med det navn!</b></p>');
|
||||
return redirect()->route("washing-machines.store");
|
||||
else { // Else - Add it
|
||||
$machine->save();
|
||||
$machines = WashingMachine::query()->paginate($request->input("limit", 20));
|
||||
@@ -127,7 +127,7 @@ class WashingMachineController extends Controller
|
||||
|
||||
// If there already is a washing machine with that name, then don't change it
|
||||
if (count($allMachines) > 0)
|
||||
return redirect()->route("washing-machines.store")->with('WashingNameExists', '<p><b>Der findes allerede en vaskemaskine med det navn!</b></p>');
|
||||
return redirect()->route("washing-machines.store");
|
||||
else { // Else - Change the name
|
||||
$machine->update($data);
|
||||
$machine->save();
|
||||
@@ -154,14 +154,17 @@ class WashingMachineController extends Controller
|
||||
return redirect()->route("washing-machines.index");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function nameCheck(Request $request){
|
||||
$washing = WashingMachine::query()->where('name', 'LIKE',$request->nameCheck)->get();
|
||||
$washing = WashingMachine::query()->where('name', 'LIKE',$request->nameCheck)->where('location_id', '=', $request->location)->get();
|
||||
if(count($washing) > 0 && $request->nameCheck !== NULL){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public function nameCheckUpdate(Request $request){
|
||||
$washing = WashingMachine::query()->where('name', 'LIKE',$request->nameCheck)->where('location_id', '=', $request->location)->where('id', '!=', $request->id)->get();
|
||||
if(count($washing) > 0 && $request->nameCheck !== NULL){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user