Fail message when making a reservation with taken machine and time
This commit is contained in:
parent
2a3a728fa3
commit
d15f406059
skolehjem
app/Http/Controllers
resources/views/app/washing-reservations
|
@ -67,15 +67,13 @@ class WashingReservationController extends Controller
|
|||
|
||||
$machineReservation = new WashingReservation($data);
|
||||
$machineReservation->user_id = auth()->user()->id;
|
||||
$machineReservation->save();
|
||||
|
||||
$saved = $machineReservation->save();
|
||||
$allMachineReservations = WashingReservation::query()->where('time', '=', $request->time)->where('machine_id', '=', $request->machine_id)->get();
|
||||
|
||||
if (!$saved) {
|
||||
return Response::detect("washing-reservations.store", [
|
||||
"washing_reservation" => $machineReservation
|
||||
]);
|
||||
if (count($allMachineReservations) > 0) {
|
||||
return redirect()->route("washing-reservations.create", ["washing_reservation" => $machineReservation])->with('ReservationExists', '<p class="text-center"><b>Der findes allerede en reservation til denne tid, men denne vaskemaskine!</b></p>');
|
||||
} else {
|
||||
$machineReservation->save();
|
||||
$reservations = WashingReservation::query()->paginate($request->input("limit", 20));
|
||||
|
||||
return redirect()->route('washing-reservations.appindex', ["reservations" => $reservations]);
|
||||
|
@ -174,7 +172,7 @@ class WashingReservationController extends Controller
|
|||
foreach ($reservations as $reservation){
|
||||
array_push($times, $reservation->time);
|
||||
}
|
||||
//2020-07-28%
|
||||
|
||||
$output = json_encode(['date' => $date, 'washingmachines' => $machines, 'unavailable_times' => $times]);
|
||||
return Response($output);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
@section("content")
|
||||
<main>
|
||||
<h1 class="text-center sde-blue mb-0">Booking Liste</h1>
|
||||
{!! session()->get('ReservationExists') !!}
|
||||
<div class="col w-100 mt-auto">
|
||||
<div class="calendar-container">
|
||||
<div class="calendar-container__header">
|
||||
|
|
Loading…
Reference in New Issue