giuseppe.petagine20183
giuseppe.petagine20183

How can I change the connection of the backend user model or of generic model? I have tried these ways but it doesn't work.

use Backend\Models\User;

...and in boot method of my plugin

1. User::extend(function($model) { $model->setConnection('master'); });

2. User::extend(function($model) { $model->addDynamicProperty('connection', 'master'); });

3. User::extend(function($model) { $model->connection = 'master'; });

4. User::extend(function($model) { $model['connection'] = 'master'; });

mjauvin
mjauvin

try:

$model->connection = App::make('db')->connection('master');

1-2 of 2