Home >Backend Development >PHP Tutorial >How to set the admin route in laravel5.2 so that only administrators can log in?

How to set the admin route in laravel5.2 so that only administrators can log in?

WBOY
WBOYOriginal
2016-07-06 13:52:51853browse

As mentioned, how to make the admin route open only to the administrator account? Ordinary logged-in users cannot access the backend. Thanks.

Reply content:

As mentioned, how to make the admin route open only to the administrator account? Ordinary logged-in users cannot access the backend. Thanks.

//Background routing
Route::group(['prefix' => 'admin', 'middleware' => 'admin.login'], function () {

<code>Route::get('index', function () {
    echo "admin/index";
});

//后台文章管理界面
Route::resource('article', 'ArticleController');</code>

});

The admin.login middleware is defined by myself and then added to Kernel.php
How to set the admin route in laravel5.2 so that only administrators can log in?

How to set the admin route in laravel5.2 so that only administrators can log in?

It can be achieved by adding middleware, subject to limitations.

In routing, adding middleware can achieve

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn