title: How to use the middleware for restricting other content based on the role? Using React Js and Laravel
body: <p>I currently setup the role based and content authorization. However i got problem when I try the to access the route of super admin still accessible. I used this instruction <a href="https://medium.com/justlaravel/how-to-use-middleware-for-content-restriction-based-on-user-role-in-laravel-2d0d8f8e94c6" rel="nofollow noreferrer">https://medium.com/justlaravel/how-to-use-middleware-for-content-restriction-based-on-user-role-in-laravel-2d0d8f8e94c6</a>  - but still no working well.</p>
  
  <p>to understand well, I will share to you what suppose to be the output and my sample coding on my middleware and api.php</p>
  
  <ol>
  <li>I have Middleware of CheckRoleRouter.php</li>
  <li>I create a unauthorized.blade.php file for new response if the user role access wrong route.</li>
  <li>I already set the middleware to the kernel.php</li>
  </ol>
  
  <p>Role: I have Super Admin = 0 and Admin = 1</p>
  
  <p><strong>Middleware:</strong></p>
  
  <pre><code>    &lt;?php
  
  namespace App\Http\Middleware;
  
  use Closure;
  use Auth;
  
  class CheckRoleRouter
  {
      /**
       * Handle an incoming request.
       *
       * @param  \Illuminate\Http\Request  $request
       * @param  \Closure  $next
       * @return mixed
       */
      public function handle($request, Closure $next)
      {
  
          //Role of users
  
          //Super Admin = 0
          //Admin = 1
  
          // how to make a middleware to prevent accessing other router based on their role.
          if ($request-&gt;user() &amp;&amp; $request-&gt;user()-&gt;role != 0)
          {
              return new Response(view('unauthorized')-&gt;with('role', 'SUPERADMIN'));
          }
  
  
          return $next($request);
      }
  }
  </code></pre>
  
  <p><strong>Api:</strong></p>
  
  <pre><code>Route::group(['middleware' =&gt; 'App\Http\Middleware\CheckRoleRouter'], function()
  {
      Route::get('list_offers','Api\BusinessOffersController@list_offers');
  });
  </code></pre>
  
  <p><strong>Kernel:</strong></p>
  
  <pre><code>'checker' =&gt; \App\Http\Middleware\CheckRoleRouter::class,
  </code></pre>
  
  <p><strong>Session:</strong> - it means i used the admin role so the logic is the router of super_admin is not accessible anymore because i used the admin.</p>
  
  <p><a href="https://i.stack.imgur.com/ajUCA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ajUCA.png" alt="local storage session role"></a></p>
  
  <p><strong>Page:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/ld5c9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ld5c9.png" alt="Super Admin Page"></a></p>