0

我有野狗 API。

这是我的 routes.php 文件:

Route::resource('test','TestController');

$api = app('api.router');
$api->version('v1',['prefix' => 'api'], function ($api) {
    $api->resource('user', 'App\Http\Controllers\API\v1\UserController');
});

在 UserController 我只能使用 API 路由??

所以我不能做 route('test.index') 因为它给了我这个错误: Route [test.index] not defined

但是 route('api.user.index') 工作正常吗?

如何使用原生 Laravel 路由,如 test.index、test.edit 等?

我看到 route() 调用 app() 函数,但我不明白它是如何工作的。这在任何地方都有记录吗?

4

2 回答 2

0

我想通了......这里讨论了这个问题: https ://github.com/dingo/api/issues/918

jenky https://github.com/dingo/api/pull/919提交了拉取请求

我只是运行“composer update”来获取最新的 Dingo API 开发版本,问题就解决了。

于 2016-05-01T12:19:37.590 回答
-1
public function index() {
    $products = Product::latest()->paginate(5);
    return view('products.index',compact('products'))
        ->with('i', (request()->input('page', 1) - 1) * 5);
}
于 2020-11-10T08:04:47.683 回答