original_string: public function search($categoryId = null, $onlyVisible = false)
      {
          $query = static::find();
          if ($categoryId) {
              $query->andWhere(['category_id' => $categoryId]);
          }
          if ($onlyVisible) {
              $query->joinWith(['category' => function ($query) {
                  $query->andWhere([Category::tableName() . '.visible' => 1]);
              }]);
              $query->andWhere([static::tableName() . '.visible' => 1]);
          }
  
          $dataProvider = new ActiveDataProvider(['query' => $query]);
          $dataProvider->sort->defaultOrder = ['sort' => SORT_ASC, 'id' => SORT_ASC];
          return $dataProvider;
      }
code: public function search($categoryId = null, $onlyVisible = false)
      {
          $query = static::find();
          if ($categoryId) {
              $query->andWhere(['category_id' => $categoryId]);
          }
          if ($onlyVisible) {
              $query->joinWith(['category' => function ($query) {
                  $query->andWhere([Category::tableName() . '.visible' => 1]);
              }]);
              $query->andWhere([static::tableName() . '.visible' => 1]);
          }
  
          $dataProvider = new ActiveDataProvider(['query' => $query]);
          $dataProvider->sort->defaultOrder = ['sort' => SORT_ASC, 'id' => SORT_ASC];
          return $dataProvider;
      }
code_tokens: public function search ( $ categoryId = null , $ onlyVisible = false ) { $ query = static :: find ( ) ; if ( $ categoryId ) { $ query -> andWhere ( [ 'category_id' => $ categoryId ] ) ; } if ( $ onlyVisible ) { $ query -> joinWith ( [ 'category' => function ( $ query ) { $ query -> andWhere ( [ Category :: tableName ( ) . '.visible' => 1 ] ) ; } ] ) ; $ query -> andWhere ( [ static :: tableName ( ) . '.visible' => 1 ] ) ; } $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query ] ) ; $ dataProvider -> sort -> defaultOrder = [ 'sort' => SORT_ASC , 'id' => SORT_ASC ] ; return $ dataProvider ; }
docstring: Searches forums.
  @param int|null $categoryId
  @return ActiveDataProvider
docstring_tokens: Searches forums .