Blogger Information
Blog 142
fans 5
comment 0
visits 129885
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Laravel中复杂点的路由分组如何写?
php开发大牛
Original
683 people have browsed it

为了偷懒,不得不写点高级的东东。

Laravel中的路由,是一个要搞定的技术点。

比如,后台管理登陆,

所有页画都要经过adminLoginAuth认证的中间件,

然后,每一组功能,都会生成一个前缀,

然后,还要为每个url进行命名管理。

如何用一个路由写法搞定???

如下面:

实例

Route::middleware(['adminLoginAuth'])->group(function () {
    
    //后台首页
    Route::get('/admin','admin\LoginController@index')->name('admin.index');
    
    //后台用户中心
    Route::prefix('admin/user')->group(function () {
        Route::name('admin.user.')->group(function () {
            Route::get('list','admin\UserController@getList')->name('list');
            Route::get('edit','admin\UserController@getEdit')->name('edit');
            ...
        });
    });

    ......
    
});

运行实例 »

点击 "运行实例" 按钮查看在线实例


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post