v0.10.0c - Fixed WashingMachine create & update AJAX

This commit is contained in:
Anders
2020-08-17 11:07:26 +02:00
parent 3bde377caa
commit 5ac480454a
5 changed files with 116 additions and 13 deletions
@@ -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;
}
}
}