Good morning.
I'm trying to use 2 mysql tables, as if they were 2 schemas, but I'm not getting it, I've tried the examples:
Multiple schemas in the Laravel database 5
More did not work, can you help me?
File .env
DB_CONNECTION=banco1
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=banco1
DB_USERNAME=root
DB_PASSWORD=
DB_CONNECTION2=banco2
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=banco2
DB_USERNAME=root
DB_PASSWORD=
Model
<?php
namespace App\Conexoes;
use Illuminate\Database\Eloquent\Model;
class Conexoes extends Model
{
//
protected $connection = 'gps';
}
Controller
namespace App\Http\Controllers\Rastreamento;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Conexoes\Positions;
use App\Rastreamento\Markers;
use Mapper;
class PosiceosController extends Controller
{
private $positions;
public function index(){
$this->setConnection('banco2');
$registros= $this->tabela->all();
}