So I noticed this today and I assume it's a doc mistake, but who knows its actually a bug. When creating multiple resource controllers, the docs say
You may register many API resource controllers at once by passing an array to the apiResources method:
Route::apiResources([ 'photos' => 'PhotoController', 'posts' => 'PostController' ]);
But for me it's saying
In Router.php line 329:
Type error: Too few arguments to function Illuminate\Routing\Router::apiResource(), 1 passed in [...]\vendor\laravel\frameworksrc\Illuminate\Support\Facades\Facade.php on line 221 and at least 2 expected
php artisan make:controller Api/FooController --resource --apiRoute::apiResource and pass all the made controllers in an array to that methodExample:
Route::apiResource([
'foo' => 'Api\Foocontroller'
]);
php artisan route:list and see the errorYou have a typo: apiResource() → apiResources()
Oh gosh, ok thanks for pointing out @staudenmeir 🤦♂️
I was missing a 's' as well. Thanks :laughing:
But why in the documentation of laravel is written without "s"?
Route::resource('photos.comments', 'PhotoCommentController');
@josendulip Both methods exist: https://laravel.com/docs/controllers#restful-partial-resource-routes
You have a typo:
apiResource()→apiResources()
it works for me
Most helpful comment
You have a typo:
apiResource()→apiResources()