This is my model:
class Product extends \\GlobalModel {
protected $table = \'product\';
}
I want to update the table name oops_
this should work with static methods also (only tested on 5.7)
use Illuminate\Database\Eloquent\Model;
function makeModel($table)
{
$model = new class extends Model
{
public static $entryTable;
public function setTable($table)
{
$this->table = static::$entryTable = $table;
}
public static function __callStatic($method, $parameters)
{
$static = (new static);
$static->setTable($static::$entryTable);
return $static->$method(...$parameters);
}
};
$model->setTable($table);
return $model;
}