doushi3189
2019-02-11 20:37
浏览 129
已采纳

在laravel 5.7中未正确显示的资源的路由名称

using laravel 5.7, i have the following code line in routes/web.php

Route::resource('admin/users', 'Admin\AdminUsersController');

when i list routes via : php artisan route:list i get the following:

|        | GET|HEAD  | admin/users             | users.index      | App\Http\Controllers\Admin\AdminUsersController@index                  | web
|        | POST      | admin/users             | users.store      | App\Http\Controllers\Admin\AdminUsersController@store                  | web
|        | GET|HEAD  | admin/users/create      | users.create     | App\Http\Controllers\Admin\AdminUsersController@create                 | web
|        | GET|HEAD  | admin/users/{user}      | users.show       | App\Http\Controllers\Admin\AdminUsersController@show                   | web
|        | PUT|PATCH | admin/users/{user}      | users.update     | App\Http\Controllers\Admin\AdminUsersController@update                 | web
|        | DELETE    | admin/users/{user}      | users.destroy    | App\Http\Controllers\Admin\AdminUsersController@destroy                | web
|        | GET|HEAD  | admin/users/{user}/edit | users.edit       | App\Http\Controllers\Admin\AdminUsersController@edit                   | web

why routes are not named following the directory structure : admin.users.method

图片转代码服务由CSDN问答提供 功能建议

使用laravel 5.7,我在routes / web.php中有以下代码行

  Route :: resource('admin / users','Admin \ AdminUsersController'); 
   
 
 

当我列出路线时:php artisan route :list我得到以下内容:

  |  |  GET | HEAD |  admin / users |  users.index |  App \ Http \ Controllers \ Admin \ AdminUsersController @index | 网络\ N |  |  POST |  admin / users |  users.store |  App \ Http \ Controllers \ Admin \ AdminUsersController @ store | 网络\ N |  |  GET | HEAD |  admin / users / create |  users.create |  App \ Http \ Controllers \ Admin \ AdminUsersController @ create | 网络\ N |  |  GET | HEAD |  admin / users / {user} |  users.show |  App \ Http \ Controllers \ Admin \ AdminUsersController @ show | 网络\ N |  |  PUT | PATCH |  admin / users / {user} |  users.update |  App \ Http \ Controllers \ Admin \ AdminUsersController @ update | 网络\ N |  | 删除|  admin / users / {user} |  users.destroy |  App \ Http \ Controllers \ Admin \ AdminUsersController @ destroy | 网络\ N |  |  GET | HEAD |  admin / users / {user} / edit |  users.edit |  App \ Http \ Controllers \ Admin \ AdminUsersController @ edit |  web 
   
 
 

为什么路由未按目录结构命名: admin.users.method

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douxiandiyo58855 2019-02-11 20:58
    已采纳

    Laravel takes the last string after slash in resource routes to decide the route name. You can refer Illuminate/Routing/ResourceRegistrar.php file's register() and prefixedResource() methods.

    点赞 打赏 评论

相关推荐 更多相似问题