This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Apache46
Apache46

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

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.