src/ngrest/base/Api.php
public function actionFilter($filterName, $query = null)
    {
        $this->checkAccess('filter');
        
        $model = $this->model;
        
        $filterName = Html::encode($filterName);
        
        if (!array_key_exists($filterName, $model->ngRestFilters())) {
            throw new InvalidCallException("The requested filter '$filterName' does not exists in the filter list.");
        }

        $find = $model->ngRestFilters()[$filterName];

        if ($query) {
            foreach ($model->getNgRestPrimaryKey() as $pkName) {
                $searchQuery = $model->ngRestFullQuerySearch($query)->select([$model->tableName() . '.' . $pkName]);
                $find->andWhere(['in', $model->tableName() . '.' . $pkName, $searchQuery]);
            }
        }

        $this->appendPoolWhereCondition($find);
        
        return new ActiveDataProvider([
            'query' => $find,
            'pagination' => $this->pagination,
            'sort' => [
                'attributes' => $this->generateSortAttributes($model->getNgRestConfig()),
            ]
        ]);
    }
public function actionFilter($filterName, $query = null)
    {
        $this->checkAccess('filter');
        
        $model = $this->model;
        
        $filterName = Html::encode($filterName);
        
        if (!array_key_exists($filterName, $model->ngRestFilters())) {
            throw new InvalidCallException("The requested filter '$filterName' does not exists in the filter list.");
        }

        $find = $model->ngRestFilters()[$filterName];

        if ($query) {
            foreach ($model->getNgRestPrimaryKey() as $pkName) {
                $searchQuery = $model->ngRestFullQuerySearch($query)->select([$model->tableName() . '.' . $pkName]);
                $find->andWhere(['in', $model->tableName() . '.' . $pkName, $searchQuery]);
            }
        }

        $this->appendPoolWhereCondition($find);
        
        return new ActiveDataProvider([
            'query' => $find,
            'pagination' => $this->pagination,
            'sort' => [
                'attributes' => $this->generateSortAttributes($model->getNgRestConfig()),
            ]
        ]);
    }
public function actionFilter ( $ filterName , $ query = null ) { $ this -> checkAccess ( 'filter' ) ; $ model = $ this -> model ; $ filterName = Html :: encode ( $ filterName ) ; if ( ! array_key_exists ( $ filterName , $ model -> ngRestFilters ( ) ) ) { throw new InvalidCallException ( "The requested filter '$filterName' does not exists in the filter list." ) ; } $ find = $ model -> ngRestFilters ( ) [ $ filterName ] ; if ( $ query ) { foreach ( $ model -> getNgRestPrimaryKey ( ) as $ pkName ) { $ searchQuery = $ model -> ngRestFullQuerySearch ( $ query ) -> select ( [ $ model -> tableName ( ) . '.' . $ pkName ] ) ; $ find -> andWhere ( [ 'in' , $ model -> tableName ( ) . '.' . $ pkName , $ searchQuery ] ) ; } } $ this -> appendPoolWhereCondition ( $ find ) ; return new ActiveDataProvider ( [ 'query' => $ find , 'pagination' => $ this -> pagination , 'sort' => [ 'attributes' => $ this -> generateSortAttributes ( $ model -> getNgRestConfig ( ) ) , ] ] ) ; }
Filter the Api response by a defined Filtername.

@param string $filterName
@param string $query An optional query to filter the response for the given search term (since 2.0.0)
@throws InvalidCallException
@return \yii\data\ActiveDataProvider
Filter the Api response by a defined Filtername .