php - Make two database connections available in a model to use in laravel 5 -


i using 2 connections in project. 1 mysql , mongo. creating separate database each user/company.

so while register need create 2 database each type mysql , mongo.

i have added line below regular eloquent in regular auth user model

use illuminate\database\eloquent\model eloquent; use jenssegers\mongodb\model eloquent; 

user class like

class user extends eloquent implements authenticatablecontract, canresetpasswordcontract

i want both connection available in same model. can switch connection use like

db::connection("connection name") 

but need comment line

use jenssegers\mongodb\model eloquent; 

to use mysql , comment regular eloquent use mongo

use illuminate\database\eloquent\model eloquent; 

is there way out include both , can switch connection anytime without commenting of them.

looking forward support.

sorry if sound irrelevant new laravel

i have tried , working fine single include

use illuminate\database\eloquent\model eloquent; 

jenssegers included , extended default eloquent create functions same alike.

i have configured package correctly , using 2 different syntax can use both database @ time.

for mysql

db::connection("mysql connection name")->table('table_name') 

for mongo

db::connection("mongo connection name")->collection('table name') 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -