'Query by category_id and locale in laravel

I need to query all articles were given cateogry_id and locale from request

example: all articles where category_id is 2 and locale is "en"

    articles
      id
      language

   article_category
     article_id
     category_id

   categories
     id
     name

what I tried

  private function filterArticleByCategory(&$query, $category_id) {

        if (!is_null($category_id)) {
            $query = $query->whereIn('articles.id', Article::select('article_id')->from('article_category')->where('category_id', $category_id ));
        }
    }


    private function filterArticleByLanguage(&$query, $lang) {
        if(!is_null($lang)) {
//            $array = explode(' ', $lang);
            #arreyVal = array_values($array)[0]
            $query = $query->where('language', $lang);
        }
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source