Do a Web site development is sure to deal with the user management, how to decide whether a user is a normal user, administrator or Super Administrator?
This is illustrated in conjunction with the laravel5.1 framework and the PHP language:
1. First we need to create a database in the Users table, which need to include the Type field and fill in the false data (normal user 0, the Administrator 100, super Administrator corresponding to 110)
2. Then edit the laravel5.1 framework (/vendor/laravel/framework/src/illuminate/foundation/auth) authenticatesusers.php This file, as follows:
3. Variable $user Gets the information of the logged-on user and then passes to three functions isstudent, ISAdmin, Issuperadmin, let's take a look at these three functions:
View user.php (/app/models), which is used as a model in the Laravel framework, simply to refer to the Users table in the corresponding database
4. Find the corresponding Type field from the database according to the information (name) that the user fills in, and compare it with the corresponding file (mooe.php) in the Config directory:
5. The decision here determines which branch of the file authenticatesusers.php (the first), which corresponds to a different route/homestudent/homeadmin/homesuperadmin Then separate the controllers in the routing (routes.php).
The above describes the LARAVEL51 framework of user rights management, including the Laravel, rights management content, I hope the PHP tutorial interested in a friend to help.