php - How to connect another database with model in laravel -


i able connect database this

db::connection('connection_2')->table("users")->get(); 

but code not working

user::connection('connection_2')->get(); 

you need set $connection property of model so:

class mymodel extends eloquent {     protected $connection = 'connection_2'; } 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -