仅使用apiReources方法

问题描述 投票:0回答:1

我正在使用Laravel创建一个api,我正在寻找一种简单的惰性方法来注册Api资源。我目前正在定义这样的路线:

Route::apiResoruce('categories', 'CategoryController')->only(['index', 'show']);

我检查了Laravel's controller documentation,看到了apiResources方法,可以立即创建多个api资源。

目标:才能将apiResourcesonly方法一起使用,例如这样

Route::apiResources(['categories' => 'CategoryController', 'products' => 'ProductController'])->only(['index', 'show']);

当前结果:

Call to a member function only() on null
laravel laravel-routing
1个回答
0
投票

长话短说(如果您不想阅读整个故事),您可以这样做:

© www.soinside.com 2019 - 2024. All rights reserved.