Laravel 5: Multi-level authorization: add/remove auth layer

You may not need 3 layers of authorization, or you may need 4. Here is how to do it.

How to remove auth layer.

Lets remove associate authorization layer.
It is very simple, just follow this list:

  • remove these files and folders
    • folder: app/models/associate
    • folder: app/http/controllers/associate
    • folder: resources/views/associate
    • files is app/routes:
      • AssociateAuthRoutes.php
      • AssociateProtectedRoutes.php
    • files in database/migrations:
      • 2016_08_12_000000_create_associates_table.php
  • edit these files (remove code pertaining to associates)
    • app/routes.php
    • resources/views/gateway.blade.php
    • config/auth.php – remove sections in: guards, providers and password brokers
  • remove database tables / rows
    • whole table table::associates
    • row containing 2016_08_12_000000_create_associates_table from table::migrations


How to add auth layer.

Just copy files listed above – use one of existing auth layers and change, e.g. associate, to user -whatever you want.

Remember to give your guard, provider and password broker same name as you give to “resources/views” folder, that would hold new auth layer blade templates.

And you are done.