v0.5.4 - Created the "reservations in location" screen and added a location option when creating reservations.
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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