public function scopeFromTable($query, $tableName)
{
$query->from($tableName);
}
$DynamicTableData = ModelName::fromTable($tableName)->get();
或者使用setTable
$model = new ModelName;
$model->setTable('table1');
public function scopeFromTable($query, $tableName)
{
$query->from($tableName);
}
$DynamicTableData = ModelName::fromTable($tableName)->get();
或者使用setTable
$model = new ModelName;
$model->setTable('table1');