v0.5.4 - Created the "reservations in location" screen and added a location option when creating reservations.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Location;
|
||||
use App\WashingMachine;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
@@ -142,10 +143,13 @@ class WashingReservationController extends Controller
|
||||
$date = $request->date;
|
||||
$datetext = $request->datetext;
|
||||
|
||||
$machines = WashingMachine::all();
|
||||
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();
|
||||
|
||||
if($request->machine_id == 0)
|
||||
$request->machine_id = WashingMachine::all()->first()->id;
|
||||
$request->machine_id = WashingMachine::query()->orderBy("name", "asc")->first()->id;
|
||||
|
||||
$reservations = WashingReservation::query()->where("machine_id", "=", $request->machine_id)->where("time", "LIKE", $datetext."%")->get();
|
||||
|
||||
@@ -155,7 +159,9 @@ class WashingReservationController extends Controller
|
||||
array_push($times, $reservation->time);
|
||||
}
|
||||
|
||||
$output = json_encode(['date' => $date, 'washingmachines' => $machines, 'unavailable_times' => $times ]);
|
||||
$locations = Location::query()->orderBy("name", "asc")->get();
|
||||
|
||||
$output = json_encode(['date' => $date, 'washingmachines' => $machines, 'unavailable_times' => $times, "locations" => $locations ]);
|
||||
return Response($output);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user