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

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

定义如下:

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

结果如下:

file

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

日拱一卒
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
最佳答案

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
6年前 评论
讨论数量: 3
朕略显ぼうっと萌

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

6年前 评论

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

6年前 评论

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
6年前 评论

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