title: Laravel get Model by Table Name
body: <p>Is there any way to get a model by table name?</p>
  
  <p>For example, I have a "User" model, its table is defined as <code>protected $table = "users"</code></p>
  
  <p>Now, what I want to do is to get the model by table name which is equal to "users".</p>
  
  <p>This function is more like the reverse of <code>Model::getTable();</code></p>
  
  <p>I have searched everywhere but I could not find a solution, perhaps I might be missing something simple?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I am building something like an API :</p>
  
  <pre><code>Route::get('/{table}', 'ApiController@api');
  Route::get('/{table}/filter', 'ApiController@filter');
  Route::get('/{table}/sort', 'ApiController@sort');
  Route::get('/{table}/search', 'ApiController@search');
  </code></pre>
  
  <p>so in the address bar, for example when I search for the "users", I could just hit on the URL:</p>
  
  <pre><code>api/users/search?id=1
  </code></pre>
  
  <p>then on the controller, something like:</p>
  
  <pre><code>public function search(){
    // get all the params
  
    // get the model function
    $model = //function to get model by table name
  
    // do some filtering, then return the model
    return $model;
  }
  </code></pre>