Eloquent to access another DB

class SomeController extends BaseController {

    public function someMethod()
    {
        $someModel = new SomeModel;

        $someModel->setConnection('mysql2'); // non-static method

        $something = $someModel->find(1);

        $something = SomeModel::on('mysql2')->find(1); // static method

        return $something;
    }

}

Create another class to extend model

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ChangeSiteM extends Model {
    //protected $connection = 'mysql-tw';

    public function __construct(){
        $this->connection = 'mysql-tw';
    }
}

Reference:

  1. https://stackoverflow.com/questions/31847054/how-to-use-multiple-databases-in-laravel