title: ErrorException in AuthServiceProvider.php Undefined variable in Laravel 5.4
body: <p>I'm trying to make a acl in Laravel 5.4. On 5.2 it used to work like this, but 5.4 is not like this anymore and it gives this error message:</p>
  
  <p>ErrorException in AuthServiceProvider.php Undefined variable:gate</p>
  
  <p>Could anyone explain why it is not working and how to fix it?
  Here is my code:</p>
  
  <pre><code> public function boot()
  {
      $this-&gt;registerPolicies();
  
      $gate-&gt;define('auth', function($user, $role=NULL){
          if($role === NULL){
              $actions = Route::current()-&gt;getAction();
  
              if(! isset($actions['role']))
                  return false;
              $role = $actions['role'];
          }
          $objRole = new Role();
          $roles = $objRole-&gt;roles($user-&gt;id);
          if(in_array($role, $roles))
              return true;
          return false;
  
      });
  
  }
  </code></pre>