public function postInit()
    {
        parent::postInit();

        if (!($v = trim($this->get('q')))) {
            return;
        }

        $m = $this->view->model;

        // if model has method addConditionLike
        if ($m->hasMethod('addConditionLike')) {
            return $m->addConditionLike($v, $this->fields);
        }

        // if it is Agile Data model
        if ($m instanceof \atk4\data\Model) {

            if (!$m->hasMethod('expr')) {
                return $m;
            }

            $expr = [];
            foreach ($this->fields as $k => $field) {
                // get rid of never_persist fields
                $f = $m->hasElement($field);
                if (!$f || $f->never_persist) {
                    unset($this->fields[$k]);
                    continue;
                }

                $expr[] = 'lower({' . $field . '}) like lower([])';
            }
            $expr = '('.implode(' or ', $expr).')';
            $expr = $m->expr($expr, array_fill(0, count($this->fields), '%'.$v.'%'));

            return $m->addCondition($expr); // @todo should use having instead
        }

        // if it is ATK 4.3 model or any other data source
        if ($m instanceof SQL_Model) {
            $q = $m->_dsql();
        } else {
            $q = $this->view->dq;
        }

        $or = $q->orExpr();
        foreach ($this->fields as $field) {
            $or->where($field, 'like', '%'.$v.'%');
        }
        $q->having($or);
    }
public function postInit()
    {
        parent::postInit();

        if (!($v = trim($this->get('q')))) {
            return;
        }

        $m = $this->view->model;

        // if model has method addConditionLike
        if ($m->hasMethod('addConditionLike')) {
            return $m->addConditionLike($v, $this->fields);
        }

        // if it is Agile Data model
        if ($m instanceof \atk4\data\Model) {

            if (!$m->hasMethod('expr')) {
                return $m;
            }

            $expr = [];
            foreach ($this->fields as $k => $field) {
                // get rid of never_persist fields
                $f = $m->hasElement($field);
                if (!$f || $f->never_persist) {
                    unset($this->fields[$k]);
                    continue;
                }

                $expr[] = 'lower({' . $field . '}) like lower([])';
            }
            $expr = '('.implode(' or ', $expr).')';
            $expr = $m->expr($expr, array_fill(0, count($this->fields), '%'.$v.'%'));

            return $m->addCondition($expr); // @todo should use having instead
        }

        // if it is ATK 4.3 model or any other data source
        if ($m instanceof SQL_Model) {
            $q = $m->_dsql();
        } else {
            $q = $this->view->dq;
        }

        $or = $q->orExpr();
        foreach ($this->fields as $field) {
            $or->where($field, 'like', '%'.$v.'%');
        }
        $q->having($or);
    }
public function postInit ( ) { parent :: postInit ( ) ; if ( ! ( $ v = trim ( $ this -> get ( 'q' ) ) ) ) { return ; } $ m = $ this -> view -> model ; // if model has method addConditionLike if ( $ m -> hasMethod ( 'addConditionLike' ) ) { return $ m -> addConditionLike ( $ v , $ this -> fields ) ; } // if it is Agile Data model if ( $ m instanceof \ atk4 \ data \ Model ) { if ( ! $ m -> hasMethod ( 'expr' ) ) { return $ m ; } $ expr = [ ] ; foreach ( $ this -> fields as $ k => $ field ) { // get rid of never_persist fields $ f = $ m -> hasElement ( $ field ) ; if ( ! $ f || $ f -> never_persist ) { unset ( $ this -> fields [ $ k ] ) ; continue ; } $ expr [ ] = 'lower({' . $ field . '}) like lower([])' ; } $ expr = '(' . implode ( ' or ' , $ expr ) . ')' ; $ expr = $ m -> expr ( $ expr , array_fill ( 0 , count ( $ this -> fields ) , '%' . $ v . '%' ) ) ; return $ m -> addCondition ( $ expr ) ; // @todo should use having instead } // if it is ATK 4.3 model or any other data source if ( $ m instanceof SQL_Model ) { $ q = $ m -> _dsql ( ) ; } else { $ q = $ this -> view -> dq ; } $ or = $ q -> orExpr ( ) ; foreach ( $ this -> fields as $ field ) { $ or -> where ( $ field , 'like' , '%' . $ v . '%' ) ; } $ q -> having ( $ or ) ; }
Process received filtering parameters after init phase.

@return Model|void
Process received filtering parameters after init phase .