Creating an Admin Area with Laravel 5

Role Based Authentication in Laravel with JWT
May 15, 2016
Laravel Authentication – The Missing Pieces
November 4, 2017
Show all

Creating an Admin Area with Laravel 5

It is a very essential feature and Laravel auth has no built-in solution.

This tutorial assumes prior knowledge of Laravel 5.

Adding a new Column to Users Table

In order for this authentication to work, we are going to need to have a column that lets us distinguish between either admins or regular users. In this case I chose to extend the pre-existing users table by adding an integer column to the schema. Once you’ve added this rollback and then migrate so that you have access to this new column.

Using Middleware

Laravel 5’s new middleware mechanism offers an exceptionally easy way to authenticate users and thus create an admin backend to manage any web apps. HTTP middleware provide a convenient mechanism for filtering HTTP requests entering your application, by utilizing these filters we can determine if the user is both logged in and features the correct access levels required to access the sensitive backend of our site. If the user requesting access to the backend of the site is not authenticated, the middleware redirects the user to the login screen.

You can read complete article here.