简体   繁体   English

Laravel 独立管理面板 |

[英]Laravel Separate Admin Panel |

I have a laravel site www.myExampleDomain.com .I want to add my admin panel in the site.我有一个 laravel 站点www.myExampleDomain.com 。我想在站点中添加我的管理面板。 While customer hit www.myExampleDomain.com they will see the customer site.when admin hit www.myExampleDomain.com/admin admin will see the admin panel.当客户点击www.myExampleDomain.com时,他们将看到客户站点。当管理员点击www.myExampleDomain.com/admin 时,管理员将看到管理面板。

so I want to keep my codes separated for customer panel and admin panel.所以我想将客户面板和管理面板的代码分开。 like: all the routes of customer will be in customer_web.php and all the routes of admin will be in admin_web.php.also all the controller for admin in adminController folder and view in AdminView folder separately.比如:customer的所有路由都在customer_web.php中,admin的所有路由都在admin_web.php中。还有所有Z594C103F2C6E04C3D8AB059F031E0C1文件夹中的Admin文件夹和视图分别在Admin文件夹中查看。 How can I handle the separation?我该如何处理分离?

One possible way is to use the Route group() with prefixes method as explained here :一种可能的方法是使用Route group() with prefixes方法如下所述:

Route groups allow you to share route attributes, such as middleware or namespaces, across a large number of routes without needing to define those attributes on each individual route.路由组允许您跨大量路由共享路由属性,例如中间件或命名空间,而无需在每个单独的路由上定义这些属性。 Shared attributes are specified in an array format as the first parameter to the Route::group method.共享属性以数组格式指定为 Route::group 方法的第一个参数。

Route::prefix('admin')->group(function () {
    Route::get('dashboard', function () {
        // Matches The "/admin/dashboard" URL
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM