Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

anonymous database tables

Tell me please it possible to use an anonymous database tables, for example, There are "table1", "table2" etc. Model -"table". Anywhere If user = 'Vasiliy' use the table "table1" else "table2".

What are the mechanisms of this?



There is a Model::getSource() function, which returns a string representing the table name for the model.

My best bet would be to override it like so:

class User extends Model
    // columns, etc...

    public function getSource() {
        if($this->user == 'Vasiliy') {
            return 'table2';
        return 'table1';


Thank you very much!