Home > Article > Backend Development > User rights management under the laravel51 framework 360 rights management User rights management Router management rights
Developing a website must involve user management. How to decide whether a user is an ordinary user, administrator or super administrator?
Here is a description combining the laravel5.1 framework and PHP language:
1. First we need to create a users table in the database, which needs to contain the type field and fill in false data (normal users correspond to 0, administrators correspond to 100, super administrator corresponds to 110)
2. Then edit the AuthenticatesUsers.php file of the laravel5.1 framework (/vendor/laravel/framework/src/illuminate/Foundation/Auth). The screenshot is as follows:
3. The variable $user obtains the information of the logged-in user, and then passes it into the three functions isStudent, isAdmin, and isSuperAdmin. Let’s take a look at these three functions:
View User.php (/app/models), the file is in As a model under the laravel framework, simply speaking, it corresponds to the users table in the database
4. Find the corresponding type field from the database according to the information (name) filled in by the user, and correspond to the config directory File (mooe.php) for comparison:
5. The judgment here determines which branch the program enters the file AuthenticatesUsers.php (the first screenshot), corresponding to different routes /homestudent /homeadmin /homesuperadmin and then in the route ( routes.php) into different controllers.
The above introduces the user rights management under the laravel51 framework, including laravel and rights management. I hope it will be helpful to friends who are interested in PHP tutorials.