You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
549 B
27 lines
549 B
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
trait DynamicallyTableModelTrait
|
|
{
|
|
protected $connection = null;
|
|
protected $table = null;
|
|
|
|
public function bind(string $connection, string $table)
|
|
{
|
|
$this->setConnection($connection);
|
|
$this->setTable($table);
|
|
}
|
|
|
|
public function newInstance($attributes = [], $exists = false)
|
|
{
|
|
// Overridden in order to allow for late table binding.
|
|
|
|
$model = parent::newInstance($attributes, $exists);
|
|
$model->setTable($this->table);
|
|
|
|
return $model;
|
|
}
|
|
|
|
}
|