public function filterByKeywords($name)
    {
        $likeBuilder = $this->app->make(LikeBuilder::class);
        /* @var LikeBuilder $likeBuilder */
        $likes = $likeBuilder->splitKeywordsForLike($name, '\W_');
        if (!empty($likes)) {
            $expr = $this->query->expr();
            $orFields = $expr->orX();
            foreach (['p.handle', 'p.name'] as $fieldName) {
                $and = $expr->andX();
                foreach ($likes as $like) {
                    $and->add($expr->like($fieldName, $this->query->createNamedParameter($like)));
                }
                $orFields->add($and);
            }
            $this->query->andWhere($orFields);
        }
    }
public function filterByKeywords($name)
    {
        $likeBuilder = $this->app->make(LikeBuilder::class);
        /* @var LikeBuilder $likeBuilder */
        $likes = $likeBuilder->splitKeywordsForLike($name, '\W_');
        if (!empty($likes)) {
            $expr = $this->query->expr();
            $orFields = $expr->orX();
            foreach (['p.handle', 'p.name'] as $fieldName) {
                $and = $expr->andX();
                foreach ($likes as $like) {
                    $and->add($expr->like($fieldName, $this->query->createNamedParameter($like)));
                }
                $orFields->add($and);
            }
            $this->query->andWhere($orFields);
        }
    }
public function filterByKeywords ( $ name ) { $ likeBuilder = $ this -> app -> make ( LikeBuilder :: class ) ; /* @var LikeBuilder $likeBuilder */ $ likes = $ likeBuilder -> splitKeywordsForLike ( $ name , '\W_' ) ; if ( ! empty ( $ likes ) ) { $ expr = $ this -> query -> expr ( ) ; $ orFields = $ expr -> orX ( ) ; foreach ( [ 'p.handle' , 'p.name' ] as $ fieldName ) { $ and = $ expr -> andX ( ) ; foreach ( $ likes as $ like ) { $ and -> add ( $ expr -> like ( $ fieldName , $ this -> query -> createNamedParameter ( $ like ) ) ) ; } $ orFields -> add ( $ and ) ; } $ this -> query -> andWhere ( $ orFields ) ; } }
Filter the results by keywords.

@param string $name
Filter the results by keywords .