title: Laravel Model's table name with variable
body: <p>I want to change the table name depending on which user is Auth.</p>
  
  <p>Why? Because when I add a dealer, I create a database client for this dealer and the name of the data is d.$dealer_id.clients. So, the user need to add a client to the table associated with is own dealer.</p>
  
  <p>I tried with setTable() :</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  use Auth;
  
  class Client extends Model
  {
      public function setTable($table)
      {
          $this-&gt;table = 'd1clients';
          return $this;
      }
      protected $fillable = ['dealer_id', 'user_id', 'type', 'first_name', 'last_name', 'phone', 'cellphone', 'email', 'stock', 'source', 'civic', 'road', 'city', 'province', 'country', 'postal_code', 'birth_date', 'driving_liscence'];
  }
  </code></pre>
  
  <p>But it don't save the client to the table.
  And this:</p>
  
  <pre><code>'diclients'
  </code></pre>
  
  <p>Should be this:</p>
  
  <pre><code>'d'.Auth::user()-&gt;dealer_id.'clients'
  </code></pre>
  
  <p>I also tried this thing:</p>
  
  <pre><code>$globalDealerId = Auth::user()-&gt;dealer_id;
  protected $table = 'd'.$globalDealerId.'clients';
  protected $fillable = ['dealer_id', 'user_id', 'type', 'first_name', 'last_name', 'phone', 'cellphone', 'email', 'stock', 'source', 'civic', 'road', 'city', 'province', 'country', 'postal_code', 'birth_date', 'driving_liscence'];
  </code></pre>
  
  <p>The documentation said that the setTable should work, but I don't know what I did wrong...</p>