title: When is the `apply` method fired on a Laravel global scope object?
body: <p>I'm attempting to implement a global scope in Laravel 4.2 by <a href="http://laravel.com/docs/4.2/eloquent#global-scopes" rel="nofollow">following the documentation</a>. I have created a <code>UserTypeTrait</code> to add a <code>UserTypeScope</code> to the global scope. This is my <code>UserTypeTrait</code>:</p>
  
  <pre><code>trait UserTypeTrait
  {
      public static function bootUserTypeTrait()
      {
          Log::info('bootUserTypeTrait fired');
          static::addGlobalScope(new UserTypeScope);
      }
  }
  </code></pre>
  
  <p>This is my <code>UserTypeScope</code>:</p>
  
  <pre><code>class UserTypeScope implements ScopeInterface
  {
      public function apply(Builder $builder)
      {
          Log::info('apply fired');
          $model = $builder-&gt;getModel();
      }
  
      public function remove(Builder $builder)
      {
          // @todo
      }
  </code></pre>
  
  <p>I'm attempting to apply this trait to my <code>Customer</code> object:</p>
  
  <pre><code>class Customer extends User
  {
      use UserTypeTrait;
  }
  </code></pre>
  
  <p>Whenever the application boots, I'm getting confirmation that the <code>bootUserTypeTrait()</code> method fired in my log file. I'd like to add a constraint to all queries related to my <code>Customer</code> model in the <code>apply</code> method of my <code>UserTypeScope</code>, but I can't figure out how to trigger the <code>apply</code> method. From the documentation, it seems that it should be triggered any time I query the model. I've tried a few tests, but none of them result in the <code>apply</code> method being fired. For example:</p>
  
  <pre><code>public function testUserTypeScopeApplyFires()
  {
      FactoryMuffin::create('Users\Customer');
      $customers = Customer::all(); // this does note fire `UserTypeScope::apply()`
      $customer = Customer::first(); // neither does this
  }
  </code></pre>
  
  <p>In my log file, I see plenty of <code>bootUserTypeTrait fired</code> and no <code>apply fired</code> entries. When is the <code>apply()</code> method invoked? I thought I followed the documentation correctly. Am I missing something?</p>