Skip to content

Commit 97eaa0a

Browse files
[9.x] Add support for passing array as the second parameter for the group method. (#40945)
* Pass array as the second parameter for group. * Update Router.php Co-authored-by: Taylor Otwell <[email protected]>
1 parent 9541779 commit 97eaa0a

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/Illuminate/Routing/Router.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Illuminate\Http\Request;
1717
use Illuminate\Http\Response;
1818
use Illuminate\Routing\Events\RouteMatched;
19+
use Illuminate\Support\Arr;
1920
use Illuminate\Support\Collection;
2021
use Illuminate\Support\Str;
2122
use Illuminate\Support\Stringable;
@@ -369,19 +370,21 @@ public function apiResource($name, $controller, array $options = [])
369370
* Create a route group with shared attributes.
370371
*
371372
* @param array $attributes
372-
* @param \Closure|string $routes
373+
* @param \Closure|array|string $routes
373374
* @return void
374375
*/
375376
public function group(array $attributes, $routes)
376-
{
377-
$this->updateGroupStack($attributes);
377+
{
378+
foreach (Arr::wrap($routes) as $groupRoutes) {
379+
$this->updateGroupStack($attributes);
378380

379-
// Once we have updated the group stack, we'll load the provided routes and
380-
// merge in the group's attributes when the routes are created. After we
381-
// have created the routes, we will pop the attributes off the stack.
382-
$this->loadRoutes($routes);
381+
// Once we have updated the group stack, we'll load the provided routes and
382+
// merge in the group's attributes when the routes are created. After we
383+
// have created the routes, we will pop the attributes off the stack.
384+
$this->loadRoutes($groupRoutes);
383385

384-
array_pop($this->groupStack);
386+
array_pop($this->groupStack);
387+
}
385388
}
386389

387390
/**

0 commit comments

Comments
 (0)