<?php

namespace ArcaSolutions\WebBundle\Repository;

use Doctrine\ORM\EntityRepository;


/**
 * FaqRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class FaqRepository extends EntityRepository
{
    /**
     * @param $keyword
     * @return array
     */
    public function searchKeyword($keyword)
    {
        $query = $this->createQueryBuilder('f');

        $or = $query->expr()->orX();
        $or->add($query->expr()->like('f.question', ':keyword'));
        $or->add($query->expr()->like('f.answer', ':keyword'));

        $query->where('f.frontend = :yes');
        $query->andWhere($or);

        $query->setParameter('yes', 'y');
        $query->setParameter('keyword', '%' . $keyword . '%');

        return $query->getQuery()->getResult();
    }
}
