v0.10.7 - Fixed washing_reservation creation on app, hopefully forever
This commit is contained in:
@@ -150,7 +150,7 @@ class WashingReservationController extends Controller
|
||||
$machines = WashingMachine::query()->where("location_id", "=", $request->location_id)->orderBy("name", "asc")->get();
|
||||
|
||||
if($request->machine_id == 0)
|
||||
$request->machine_id = WashingMachine::query()->orderBy("name", "asc")->first()->id;
|
||||
$request->machine_id = WashingMachine::query()->where("location_id", "=", $request->location_id)->orderBy("name", "asc")->first()->id;
|
||||
|
||||
$reservations = WashingReservation::query()->where("machine_id", "=", $request->machine_id)->where("time", "LIKE", $datetext."%")->get();
|
||||
|
||||
@@ -162,7 +162,41 @@ class WashingReservationController extends Controller
|
||||
|
||||
$locations = Location::query()->orderBy("name", "asc")->get();
|
||||
|
||||
$output = json_encode(['date' => $date, 'washingmachines' => $machines, 'unavailable_times' => $times, "locations" => $locations ]);
|
||||
$output = json_encode(['date' => $date, 'washingmachines' => $machines, 'unavailable_times' => $times, "locations" => $locations, "machine_id" => $request->machine_id, "location_id" => $request->location_id ]);
|
||||
return Response($output);
|
||||
}
|
||||
}
|
||||
|
||||
public function getMachines(Request $request){
|
||||
if($request->ajax()){
|
||||
if($request->location_id == 0)
|
||||
$request->location_id = Location::all()->first()->id;
|
||||
|
||||
$machines = WashingMachine::query()->where("location_id", "=", $request->location_id)->orderBy("name", "asc")->get();
|
||||
|
||||
$output = json_encode(["washingmachines" => $machines]);
|
||||
return Response($output);
|
||||
}
|
||||
}
|
||||
|
||||
public function getTimes(Request $request){
|
||||
if($request->ajax()){
|
||||
if($request->location_id == 0)
|
||||
$request->location_id = Location::all()->first()->id;
|
||||
|
||||
if($request->machine_id == 0)
|
||||
$request->machine_id = WashingMachine::query()->where("location_id", "=", $request->location_id)->orderBy("name", "asc")->first()->id;
|
||||
|
||||
|
||||
$reservations = WashingReservation::query()->where("machine_id", "=", $request->machine_id)->where("time", "LIKE", $request->datetext."%")->get();
|
||||
|
||||
$times = [];
|
||||
|
||||
foreach ($reservations as $reservation){
|
||||
array_push($times, $reservation->time);
|
||||
}
|
||||
|
||||
$output = json_encode(["unavailable_times" => $times]);
|
||||
return Response($output);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user