aboutsummaryrefslogtreecommitdiff
path: root/app/Http/Controllers/ReservationsController.php
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2020-11-16 18:18:19 +0100
committerMateja <mail@matejamaric.com>2020-11-16 18:18:19 +0100
commitaed493eb95bf660145003f024434296c91d1c8c3 (patch)
treebb838a90230c5904b4465badaa70031f56086159 /app/Http/Controllers/ReservationsController.php
parent772fdfb0c6e520e429b1a637747b2289f6dffe20 (diff)
downloadyota-laravel-aed493eb95bf660145003f024434296c91d1c8c3.tar.gz
yota-laravel-aed493eb95bf660145003f024434296c91d1c8c3.zip
Validate from and to date on reserve from. Copy activities.js to
reservations.js
Diffstat (limited to 'app/Http/Controllers/ReservationsController.php')
-rw-r--r--app/Http/Controllers/ReservationsController.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/Http/Controllers/ReservationsController.php b/app/Http/Controllers/ReservationsController.php
index 1865f46..249d18a 100644
--- a/app/Http/Controllers/ReservationsController.php
+++ b/app/Http/Controllers/ReservationsController.php
@@ -92,6 +92,14 @@ class ReservationsController extends Controller
$validator = Validator::make($request->all(), $rules, $messages);
+ $validator->after(function ($validator) use ($request) {
+ $fromStamp = strtotime($request->sdate . ' ' . $request->stime);
+ $toStamp = strtotime($request->edate . ' ' . $request->etime);
+ if (!($fromStamp < $toStamp)) {
+ $validator->errors()->add('time', 'FROM time and date needs to be before TO time and date.');
+ }
+ });
+
if ($validator->fails()) {
return Redirect::back()
->withErrors($validator)