diff --git a/skolehjem/app/Http/Controllers/LocationController.php b/skolehjem/app/Http/Controllers/LocationController.php index d766b01..92af4c5 100644 --- a/skolehjem/app/Http/Controllers/LocationController.php +++ b/skolehjem/app/Http/Controllers/LocationController.php @@ -72,11 +72,11 @@ class LocationController extends Controller * Display the specified resource. * * @param \App\Location $location - * @return \Illuminate\Http\Response + * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function show(Location $location) { - + return view("admin.locations.show", [ "location" => $location]); } /** diff --git a/skolehjem/app/Http/Controllers/WashingReservationController.php b/skolehjem/app/Http/Controllers/WashingReservationController.php index 4da0d9e..11c77a5 100644 --- a/skolehjem/app/Http/Controllers/WashingReservationController.php +++ b/skolehjem/app/Http/Controllers/WashingReservationController.php @@ -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); } } diff --git a/skolehjem/resources/views/admin/events/index.blade.php b/skolehjem/resources/views/admin/events/index.blade.php index 536ef83..01a1d5a 100644 --- a/skolehjem/resources/views/admin/events/index.blade.php +++ b/skolehjem/resources/views/admin/events/index.blade.php @@ -25,7 +25,7 @@