diff options
author | Mateja <mail@matejamaric.com> | 2020-11-16 18:18:19 +0100 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2020-11-16 18:18:19 +0100 |
commit | aed493eb95bf660145003f024434296c91d1c8c3 (patch) | |
tree | bb838a90230c5904b4465badaa70031f56086159 /app | |
parent | 772fdfb0c6e520e429b1a637747b2289f6dffe20 (diff) | |
download | yota-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')
-rw-r--r-- | app/Http/Controllers/ReservationsController.php | 8 |
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) |