title: Is there a way to specify argument as collection of a certain model in Laravel?
body: <p>I have a function that only accepts an Eloquent <code>Collection</code>. This is okay, but really I'd like to specify that it can only accept collections of a certain model. Is it possible to specify that we only want a collection of a certain type to function arguments?</p>
  <p>This is what I have now:</p>
  <pre class="lang-php prettyprint-override"><code>use Illuminate\Database\Eloquent\Collection as EloquentCollection;
  
  /**
   * @param EloquentCollection $companies
   * @return array
   */
  public function transformCompanies(EloquentCollection $companies)
  {
      $companies-&gt;each(function($company){
         // do things with the company object..
      });
      
  }
  </code></pre>
  <p>The problem I see with it is that it accepts any type of collection. Could I do something like <code>public function transformCompanies(CompaniesCollection $companies)</code> or how does that work? What would the <code>use</code> statement be at the top if we wanted this function to only accept an Eloquent collection of the company model?</p>