title: Laravel 6 perform role based routing
body: <p>I have a route group with different routes. I want to have different role levels access without changing the URL of the application.</p>
  <p>For example I want to have /admin as the route and then I want to allow or disallow users based on their roles. Basically, I want every user to be able to see the same page but with different menu options(I know how to do this) but also secure the links from direct access.</p>
  <p>Is there a nice way to achieve that without the need of using different middlewares seperately on each route? Since there doesn't seem to be a way to retrieve the $request variable inside the web.php file but only inside a controller. I'm using the sentinel package for auth.</p>
  <p>Some sample code of my web.php:</p>
  <pre><code>Route::group(
  ['prefix' =&gt; 'admin', 'middleware' =&gt; 'customer', 'as' =&gt; 'admin.'],
  function () {
      // Ad list
      Route::get('getMyAnnonsList', 'Admin\BackEndController@getMyAdList')-&gt;name('getMyAdList');       
      }
  );
  </code></pre>
  <p>Great answer by @lagbox. This is what I did in the end. Very elegant.</p>
  <p>web.php:</p>
  <pre><code>Route::group(['prefix' =&gt; 'admin', 'as' =&gt; 'admin.'], function () {
  Route::middleware('admin:admin,user')-&gt;group(function(){
              Route::get('getMyAnnonsList', 'Admin\BackEndController@getMyAdList')-&gt;name('getMyAdList'); 
          });
  });
  </code></pre>
  <p>middleware:</p>
  <pre><code>public function handle($request, Closure $next, ...$roles)
  {      
      if (!Sentinel::check()) 
          return redirect('admin/signin')-&gt;with('info', 'You must be logged in!');
       
      foreach($roles as $role)        
          if($role == Sentinel::getUser()-&gt;roles[0]-&gt;slug)
              return $next($request);        
     
      return redirect()-&gt;back();  
  }
  </code></pre>