belongsTo(Role::class); } public function scopeOnlyProjectManager($q) { if (env('DB_DATABASE')) { return $q->whereHas('role', function ($q) { $q->from( env('DB_DATABASE') . '.roles' )->where('name', DB::raw('LOWER("project manager")')); }); } return $q; } public function user() { return $this->setConnection('mysql_hris') ->hasOne(User::class, 'id', 'user_id'); } }