hasMany('App\Models\DirectConnection', 'server_id', 'id'); } public function credentials_info(){ return $this->hasMany('App\Models\ServerCredential', 'server_id', 'id'); } public function modified_by_info(){ return $this->hasOne('App\Models\SystemUser', 'id', 'last_modified_by_id'); } public function getRootPasswordAttribute(){ $credentials = $this->credentials_info; foreach ($credentials as $value) { if ($value->username == 'root') { return $value->password; } } } }