title: Laravel Repositories and Eloquent Models
body: <p>After reading a few tutorials and mostly watching videos on <code>Laracasts</code>, I was considering adding an abstraction layer in my website using <code>Repositories</code> which would be injected in my <code>Controllers</code> through an interface. The <code>Repositories</code> are there to abstract how the <code>Model</code> is retrieved and hide some business logic. Using the <code>Bind</code> method available in <code>Laravel</code>, this seemed super easy and convenient.</p>
  
  <p>This sounds super interesting to add <code>unit tests</code> to a project, but I fail to understand how the <code>Model</code> should be handled. </p>
  
  <p>For example, let's say we're trying to hide the good old <code>User</code> model behind a repository, by creating:</p>
  
  <pre><code>interface UserRepositoryInterface {
      public function getAll();
      // ...
  }
  </code></pre>
  
  <p>Then, to support the standard <code>User</code> model provided by Laravel, defined as:</p>
  
  <pre><code>class User extends Eloquent implements UserInterface, RemindableInterface {
      // ...
  }
  </code></pre>
  
  <p>We create an <code>Eloquent</code> implementation of the <code>UserRepositoryInterface</code>:</p>
  
  <pre><code>class EloquentUserRepository extends UserRepositoryInterface {
      public function getAll() {
          return User::all();
      }
  }
  </code></pre>
  
  <p>The part that I don't understand is that now, the <code>Repository</code> doesn't return a "generic" <code>Model</code>, it returns an <code>Eloquent</code> model!  It doesn't make sense to me that other <code>Repositories</code> should return the same type of <code>Model</code>, and if it's not the case, what's the point of having <code>Repositories</code> if there is no correlation at all between the <code>Models</code> returned?</p>
  
  <p><strong>What then is the proper usage of the <code>Repository</code> pattern within <code>Laravel</code>?</strong></p>