Get data from view to composer from get_the_terms()

If you can do all loop and other conditions in Composer file and return the array with desired values - and used those array to display the data in template.

public static function boliger()
  {

    $args = [
      'post_type' => 'bolig',
      'posts_per_page' => -1,
      'order' => 'DESC',
      'tax_query' => [
        [
          'taxonomy' => 'boligtype',
          'field' => 'slug',
          'terms' => $terms,
        ],
      ],
    ];


    $query = new WP_Query($args);
    $returnBolig = [];
     while ( $query->have_posts() ) : $query->the_post();
       $term = get_the_terms(get_the_ID(), 'omrade');
       $returnBolid[get_the_ID()]['title] = get_the_title();
        $returnBolid[get_the_ID()]['term] = $term;
     endwhile;

    return $returnBolig;
  }