路由名称前缀:/admin.users 无法访问?

路由名称前缀:/admin.users无法访问?

定义如下:

Route::name('admin.')->group(function () {
    Route::get('users', function () {
        // Route assigned name "admin.users"...
        return 'hh';
    })->name('users');
});

结果如下:

file

按照文档中的例子写的,不知道是自己哪里没有理解对?
Thanks!

日拱一卒
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
最佳答案

I understand it now, thanks for the help from both of you!

Show some process images to remember more firmly

  • In the routes/web.php

    Route::name('admin.')->group(function () {
        Route::get('users', function () {
            return 'Route Name Prefixes';
        })->name('users');
    });
  • Invoke it in the User controller

    public function create()
    {
        return redirect()->route('admin.users');
    }
  • Go to http://la57.study/users/create, then there is a 302 redirect!
    file
    file
5年前 评论
讨论数量: 3

I understand it now, thanks for the help from both of you!

Show some process images to remember more firmly

  • In the routes/web.php

    Route::name('admin.')->group(function () {
        Route::get('users', function () {
            return 'Route Name Prefixes';
        })->name('users');
    });
  • Invoke it in the User controller

    public function create()
    {
        return redirect()->route('admin.users');
    }
  • Go to http://la57.study/users/create, then there is a 302 redirect!
    file
    file
5年前 评论
朕略显ぼうっと萌

这个不应该是访问 /users 路径吗? name 只是给 这个路径起了个名字,在控制器内跳转到时候指定name 就可以跳转到路由

5年前 评论

这个是名称前缀,访问的路径还是/users 可以用route('admin.users')获取这个名称的url

5年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!