0

I am starting with a new multi-tenant applicaiton, i followed this as guide http://fideloper.com/laravel-multiple-database-connections.

So in my model i have

class Manufacturer extends Model
{
    protected $connection = 'secondDB';
    ...
}

I know i can query the second database like this:

$users = DB::connection('secondDB')->select(...);

But how do i query the model? This doesn't work:

Manufacturer::create($attributes);
Omer Farooq
  • 3,462
  • 4
  • 28
  • 54

3 Answers3

0

Try this (removing Environment Configuration)

http://tutsnare.com/connect-multiple-databases-in-laravel/

Autista_z
  • 2,458
  • 13
  • 24
0

Hey here you can do like

    $Manufacturer = new Manufacturer;

    $Manufacturer->setConnection('secondDB');

    $result= $Manufacturer->find(1);

    return $result;

You can look at this How to use multiple database in Laravel

Community
  • 1
  • 1
Himanshu Raval
  • 760
  • 6
  • 17
0

Try this:

$manufacturer = new Manufacturer();
$manufacturer->setConnection('secondDB');

$this->create($attributes);

Hope this one help you.

prava
  • 3,698
  • 2
  • 21
  • 34