doushi3189
2019-02-11 20:37 阅读 119
已采纳

在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

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    douxiandiyo58855 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.

    点赞 评论 复制链接分享

相关推荐