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,754
  • 6
  • 31
  • 60

3 Answers3

0

Try this (removing Environment Configuration)

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

Autista_z
  • 2,491
  • 15
  • 25
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
  • 790
  • 7
  • 19
0

Try this:

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

$this->create($attributes);

Hope this one help you.

prava
  • 3,916
  • 2
  • 24
  • 35