I'd prefer doing it this way:
public function userRelations()
{
return UserRelation::where(function($q) {
/**
* @var Builder $q
*/
$q->where('user_id',$this->id)
->orWhere('related_user_id',$this->id);
});
}
public function getUserRelationsAttribute()
{
return $this->userRelations()->get();
}