From 1c8fe067aaa16ee6d15714bfd0d32416209a63bc Mon Sep 17 00:00:00 2001 From: vvlrad Date: Wed, 14 Feb 2024 10:41:14 +0100 Subject: [PATCH] reproduce bug from issue #50083 --- .../Controllers/AvailabilityController.php | 14 ++++++++ app/Http/Requests/AvailabilityRequest.php | 36 +++++++++++++++++++ resources/views/welcome.blade.php | 31 +++++++++++++++- routes/web.php | 3 ++ 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/AvailabilityController.php create mode 100644 app/Http/Requests/AvailabilityRequest.php diff --git a/app/Http/Controllers/AvailabilityController.php b/app/Http/Controllers/AvailabilityController.php new file mode 100644 index 0000000..369b4a7 --- /dev/null +++ b/app/Http/Controllers/AvailabilityController.php @@ -0,0 +1,14 @@ +all()); + } +} diff --git a/app/Http/Requests/AvailabilityRequest.php b/app/Http/Requests/AvailabilityRequest.php new file mode 100644 index 0000000..046c8f6 --- /dev/null +++ b/app/Http/Requests/AvailabilityRequest.php @@ -0,0 +1,36 @@ +|string> + */ + public function rules(): array + { + $dateRange = explode(' - ', $this->date_range); + + $this->merge([ + 'start_date' => $dateRange[0], + 'end_date' => $dateRange[1], + ]); + + return [ + 'start_date' => ['required', 'date'], + 'end_date' => ['required', 'date', 'after_or_equal:start_date'], + ]; + } +} diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php index 16c41df..7c722fd 100644 --- a/resources/views/welcome.blade.php +++ b/resources/views/welcome.blade.php @@ -6,7 +6,36 @@ Laravel Bug Report #50083 - + +

Bug Report Laravel Issue #50083

+ +

Explanation

+

+ On Submit, you should get a dump from the Availibility controller. But with the current laravel version, you only get a redirect and validation errors. + When adding $rules = method_exists($this, 'rules') ? $this->container->call([$this, 'rules']) : []; back to laravel/framework/src/Illuminate/Foundation/Http/FormRequest.php Line 118 it works as expected. +

+ +
+ @csrf + + + +
+ +

Errors

+ + diff --git a/routes/web.php b/routes/web.php index d259f33..f047c20 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,5 +1,6 @@ name('availability.store');