title: How to use multiple Middleware groups on Laravel?
body: <p>I'm trying to restrict the access of routes to only some types of users in my site that I'm writing with Laravel 5.7, right now I'm trying to do it with middlewares.</p>
  
  <p>For each user's level I have a middleware with this code(with a variation on the type):</p>
  
  <pre><code>public function handle($request, Closure $next)
  {
      if(Auth::user()-&gt;type==3)
          return $next($request);
      else
          return redirect()-&gt;route('dashboard');
  }
  </code></pre>
  
  <p>And in the <em>kernel.php</em> file, I have them written like this:</p>
  
  <pre><code>protected $routeMiddleware = [
      ...
      'teacher' =&gt; \App\Http\Middleware\RedirectIfTeacher::class,
      ...
  ]
  </code></pre>
  
  <p>In my application each user has a level, which starts from 1 to 5, but each level has individual views and some shared views, but I can't manage to redirect views for more than just one type of user because I can't make them work when I use more than one middlewares on a route (or routes) that are shared with more than two types of users.</p>
  
  <p>When I try it justs ignores the second or more middlewares and redirects to the route <em>dashboard</em> which is the route for redirecting if the type of user can't enter the desired view.</p>
  
  <p>Right now I've tried with this code:</p>
  
  <pre><code>Route::group(['middleware' =&gt; ['administrator','teacher','student']], function(){
  </code></pre>
  
  <p>And with this code:</p>
  
  <pre><code>Route::group(['middleware' =&gt; ['administrator' OR 'teacher' OR 'student']], function(){
  </code></pre>
  
  <p>Also I tried with this style:</p>
  
  <pre><code>Route::group(['middleware' =&gt; ['administrator|teacher|student']], function(){
  </code></pre>
  
  <p>Without getting any luck, is there anything what am I doing wrong? or is there a better way to do what I'm trying to achieve, thanks in advance!.</p>