Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Repositories/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,11 @@ public function __call($method, $parameters)
*
* @param Router $router
* @param array $attributes
* @param bool $wrap Choose the routes defined in the @routes method, should be wrapped in a group with attributes by default.
* If true then all routes will be grouped in a configuration attributes passed by restify, otherwise
* you should take care of that, by adding $router->group($attributes) in the @routes method
*/
public static function routes(Router $router, $attributes)
public static function routes(Router $router, $attributes, $wrap = false)
{
$router->group($attributes, function ($router) {
// override for custom routes
Expand Down
15 changes: 10 additions & 5 deletions src/RestifyCustomRoutesProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,18 @@ protected function registerRoutes()

$parameters = $method->getParameters();

if (count($parameters) === 2 && $parameters[1] instanceof \ReflectionParameter) {
// $config = array_merge($config, $parameters[1]->getDefaultValue());
$wrap = [];

if (count($parameters) >= 2 && $parameters[1] instanceof \ReflectionParameter) {
$default = $parameters[1]->isDefaultValueAvailable() ? $parameters[1]->getDefaultValue() : [];
$config = array_merge($config, $default);
}

if (count($parameters) === 3) {
$wrap = ($parameters[2]->isDefaultValueAvailable() && $parameters[2]->getDefaultValue()) ? $config : [];
}

Route::group([], function ($router) use ($repository, $config) {
if ($repository === 'Binaryk\LaravelRestify\Tests\RepositoryWithRoutes') {
}
Route::group($wrap, function ($router) use ($repository, $config) {
$repository::routes($router, $config);
});
});
Expand Down