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