Build administrator login into a Laravel 5 app

Connor Leech
Employbl
Published in
3 min readMar 1, 2018

--

Get ready to administrate.

Authorization can be tricky. There are thousands of posts about how to perform authentication, but actually verifying who someone is and managing user permissions can be a whole can of worms. Fortunately, Laravel has systems in place that make a tiered login system very easy to implement.

Before we get started I’d like to give props 👏 to Nick Basile and his excellent blog posts on this topic. To add authentication to a Laravel 5 app, all you need is one command:

$ php artisan make:auth

That’s it. If you’re new to Laravel, welcome. For Laravel developers this feature has been around for a long time. Now we’ve got our auth system with login forms and everything. That all works, but for the purposes of this post we’re interested in authorization.

Source code for this article is available on github

These two commits are where it all went down.

Easy solution for making a Laravel admin page using custom middleware

I am using Laravel 5.5 right now, the latest release. The only specific Laravel 5.5 thing going on is the @guest helper in the frontend Blade directives. In the HTML section of the application, these helpers allow us to easily check if the user is logged in or…

--

--

Connor Leech
Employbl

Girl Dad x 2. Cofounder @Employbl. Software Engineer @CommentSold.