I'm creating an api with Laravel and I am looking for an easy lazy way to to register Api resources. I'm currently defining my routes like this:
Route::apiResource('categories', 'CategoryController')->only(['index', 'show']);
I checked Laravel's controller documentation and I saw apiResources
method which I can create multiple api resources at once.
the goal:
is to be able to use apiResources
with only
method like this
Route::apiResources(['categories' => 'CategoryController', 'products' => 'ProductController'])->only(['index', 'show']);
current result:
Call to a member function only() on null