K
K
Konstantin2016-01-13 14:05:08
Laravel
Konstantin, 2016-01-13 14:05:08

How to work with different databases in Eloquent ORM?

Hello. Faced a small problem. There are 2 DB. One sqlite second mysql. The default is sqlite. I want to add data to mysql database. I make a request But the request goes not to mysql, but to sqlite because of this an error appears that there is no such table. That also doesn't work
Firm::on('mysql')->create($request->all());

$firm->name = $request->name;
    .....
    $firm->url = $request->url;

    $firm->on('mysql')->save();

How do I store data in mysql?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gregory, 2016-01-13
@kostik34

And correctly swears - the table is in mysql.
If all entities Firmare stored in mysql, then it is worth Firmredefining the property in the model protected $connection, then everything will work relatively transparently in the formFirm::create(...)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question