title: Scope-like function to return Model
body: <p>The answers to <a href="https://stackoverflow.com/questions/38951160/eloquent-query-scope-return-builder-instead-of-model-when-using-phpunit">this question</a> explain that Model Scopes are not meant to return anything but a Query Builder instance and custom getters should be used to return Model instances.</p>
  
  <p><strong>Problem</strong></p>
  
  <p>In my case I have a <code>User</code> and <code>Contract</code> Model, where a User has many Contracts. The Contract periods may overlap, but at any given time, only the Contract with the latest start date should be considered valid (e.g. given Contract 1 from <code>2017-01-01</code> to <code>2017-07-31</code> and Contract 2 from <code>2017-06-01</code> to <code>2017-12-31</code>, for <code>2017-07-01</code> Contract 2 should be returned)</p>
  
  <p><strong>Current solution</strong></p>
  
  <p>Using scopes I always have to call <code>-&gt;first()</code>:</p>
  
  <pre><code>public function scopeByDate(Builder $query, $date) {
      return $query-&gt;whereDate('start', '&lt;=', $date)
                   -&gt;whereDate('end', '&gt;=', $date)
                   -&gt;orderBy('start', 'desc');
  }
  public function scopeCurrent(Builder $query) {
      return $this-&gt;scopeByDate($query, date('Y-m-d'));
  }
  ...
  $user-&gt;contracts()-&gt;byDate('some-date')-&gt;first();
  $user-&gt;contracts()-&gt;current()-&gt;first();
  </code></pre>
  
  <p><strong>(Worse?) alternative solutions</strong></p>
  
  <p>Otherwise I could make <code>byDate()</code> and <code>current()</code> static, accepting either a <code>Builder</code> (looks bad to me) or a <code>User</code> (even worse?) instance and manually pass the parameters like</p>
  
  <pre><code>public static function byDate(Builder $query, $date) {
      return $query-&gt;whereDate(...)-&gt;whereDate(...)-&gt;orderBy(...)-&gt;first();
  }
  ...
  Contract::byDate($user-&gt;contracts(), 'some-date');
  </code></pre>
  
  <p>or</p>
  
  <pre><code>public static function byUserAndDate(User $user, $date) {
      return $user-&gt;contracts()-&gt;where...-&gt;where...-&gt;orderBy(...)-&gt;first()
  }
  ...
  Contract::byUserAndDate($user, 'some-date');
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>Is there some way I can call <code>byDate()</code> or <code>current()</code> directly on the query builder (relation) like scopes without passing additional parameters and return a model instance instead of a builder and having to call <code>first()</code> every time?</p>