Level 5
I have the same issue..
i tried the following:
$obj = CandidateAdmission::on('legacy_mysql')->first();
$obj = (new CandidateAdmission())->setConnection('legacy_mysql')->first();
no luck..
Disregard this. I recreated my app from scratch just to test the setup and it worked just fine. I must've boogered it up somewhere.
I am trying to have my model connect to a different database. I have my two connections setup in my database.php and I have my model setup. It is still looking for the default 'mysql' connection instead of using the 'pacsys' connection.
Anyone have any idea why? If I switch the 'mysql' credentials to the 'pacsys' database, everything works fine.
PDOException in Connection.php line 319:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'forge.analysis' doesn't exist
Analysis.php
<?php
namespace App\Models\Lab;
use Illuminate\Database\Eloquent\Model;
class Analysis extends Model
{
protected $connection = 'pacsys';
protected $table = 'analysis';
database.php
'pacsys' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'pacsys',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'mysql' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'forge',
'username' => 'forge',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
Please or to participate in this conversation.