Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Add support for passing array as the second parameter for the group method. #40945

Merged
merged 2 commits into from
Feb 10, 2022

Conversation

hossein-zare
Copy link
Contributor

Hi.

What's this PR for? (example):
in the RouteServiceProvider file:

Route::middleware('web')
   ->namespace($this->namespace)
      ->group(base_path('routes/account/web.php'));

Route::middleware('web')
   ->namespace($this->namespace)
      ->group(base_path('routes/account/staff.php'));

can be written as follows

Route::middleware('web')
   ->namespace($this->namespace)
      ->group([
         base_path('routes/account/web.php'),
         base_path('routes/account/staff.php')
       ]);

Both of them with the same middleware and namespace in just an array.

Reasons why this PR won't break other features:

  1. The original group method only accepts \Closure|string as the second parameter which is $routes, so passing an array won't mess around.

    The original group:

    /**
      * Create a route group with shared attributes.
     *
     * @param  array  $attributes
     * @param  \Closure|string  $routes
     * @return void
     */
    public function group(array $attributes, $routes)
  2. It's only one simple commit, I also tested it on a real/ready project.

I ❤ Laravel

@hossein-zare hossein-zare changed the title Support passing array as the second parameter for the group method. [9.x] Add support for passing array as the second parameter for the group method. Feb 10, 2022
@taylorotwell taylorotwell merged commit 97eaa0a into laravel:9.x Feb 10, 2022
@aronpc
Copy link

aronpc commented Mar 7, 2022

#28418

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants