I'm a beginner in Laravel and I'm trying to get data from a DB with multiple Postgresql schemas with Laravel 5.1 and it's bringing me an error
What configuration should I make for the model to correctly access the table of that schema?
Directly from postgres would write the query this way:
SELECT * FROM cadastro.escolaridade
SELECT * FROM schema.tabela
ErrorException in TestController.php line 13: Use of undefined constant cadastre - assumed 'cadastre'
Database.php
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
],
Model
<?php
namespace App\Models\Programas;
use Illuminate\Database\Eloquent\Model;
class Cadastro extends Model
{
}
Controller
<?php
namespace App\Http\Controllers;
use App\Models\Programas\Cadastro;
class TesteController extends Controller
{
public function getIndex()
{
$escolaridade = cadastro.escolaridade::all();
return view('programas.escrituras.index', compact('escolaridade'));
}
View
@forelse($escolaridade as $descricao)
<p><b>Grau de Escolaridade:</b>{{$descricao->descricao}}</p>
@empty
<p>Nenhum Grau Cadastrado!</p>
@endforelse