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

filehandler - java open files not cleaned, even when the process is killed -

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -