I am trying to make a polymorphic relationship between two database tables.
database1: SaleReport database2: ThreadConnection
under SaleReport on database1
public function relates(){
return $this->morphMany(ThreadConnection::class, 'relation');
}
on ThreadConnection at database2
public function relation(){
return $this->morphTo();
}
But when i try to get the relation like
$salereport = App\SaleReport::find(1);
$salereport->relates
Illuminate/Database/QueryException with message 'SQLSTATE[42S02]:
Base table or view not found: 1146 Table 'database1.thread_connections'
doesn't exist (SQL: select * from `thread_connections` where
`thread_connections`.`relation_id` = 484694 and
`thread_connections`.`relation_id` is not null and
`thread_connections`.`relation_type` = App/SaleReport)'
I have also tried to define the database connection into the ThreadConnection
$this->setConnection('database2')->morphTo();
But that doesn't worked either!
Any suggestion would be appriciate