title: Generic methods in Laravel controller
body: <p>I have my controllers split in 2 sections: <code>App/Http/Controllers</code> &amp; <code>App/Api/Controllers</code>. Most of these controllers have 4/5 methods in common, and nothing changes between them apart from the Eloquent Model name e.g. <code>User</code></p>
  
  <p>How can I abstract these methods away into their own controller that the other controllers can extend and still use Eloquent? Is there any method I've missed that can provide the Eloquent name of the parent controller?</p>
  
  <p>I thought about just setting a var like `modelName = 'User' and using that with var vars, but I would prefer a completely "lazy" solution where I don't have variable to change.</p>
  
  <p>Pseudo Example:</p>
  
  <pre><code>&lt;?php
  class ApiController extends Controller
  {
      public function index()
      {
          $model = ParentModelName::all();
  
          return response()-&gt;json($model);
      }
  }
  </code></pre>