I have a multi-connection application. Model Department
is on a different connection from model CutOff
.
I have a relationship in my CutOff
that looks like this:
public function department()
{
$department = new Department();
$database = $department->getConnection()->getDatabaseName();
return $this->belongsTo('App\Department', 'department_id', "$database.department.id");
}
So I try to call it like this from my view ...
$cut_off->department->name;
I get this error:
ErrorException (E_ERROR)
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.
id
= ? limit 1' at line 1 (SQL: select * fromdepartments
wheredepartments
.uni_main
.department
.id
= 2 limit 1) (View: C:\wamp\www\university\resources\views\utme\dashboard\cut_off\index.blade.php)
Please how do I get around this?