I'd also like to know this. I am having great difficulty implementing an admin role to the Laravel 5.2 built in auth.
Using 5.2 auth scaffold for roles
I know there are a million search results for implementing roles in Laravel, but I want to keep things ultra simple. I am using the auth scaffold that comes with 5.2 (php artisan make:auth). My app has front-end (public) users, and back-end (admin) users. For the admin users it's been easy: I put all my routes in a group with the auth middleware:
Route::group(['prefix' => 'admin', 'middleware' => 'auth'], function() {
[admin routes]
});
What I would like to do is create a similar group of front-end routes, using the same auth middleware. I saw this tutorial on passing parameters to middleware in 5.1. So something like this would be good:
Route::group(['prefix' => 'admin', 'middleware' => 'auth:public'], function() {
[front-end routes]
});
But the tutorial creates new middleware for this. Can I use the existing auth scaffolding? In the tutorial the $role parameter is where the $guard parameter is in the default handle method. What is the relation between these? Can $guard be used to create roles? I'm pretty new to this, so any advice is much appreciated.
Please or to participate in this conversation.