LARAVEL51 User Rights Management under the framework Rights Management user Rights Management router management rights

Source: Internet
Author: User
Tags php language
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.