<?php

namespace Lc\ShopBundle\Repository;

use Doctrine\ORM\EntityManager;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\ReductionCreditInterface;

/**
 * @method ReductionCreditInterface|null find($id, $lockMode = null, $lockVersion = null)
 * @method ReductionCreditInterface|null findOneBy(array $criteria, array $orderBy = null)
 * @method ReductionCreditInterface[]    findAll()
 * @method ReductionCreditInterface[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 */
class ReductionCreditRepository extends BaseRepository implements DefaultRepositoryInterface
{

        public function getInterfaceClass()
        {
                return ReductionCreditInterface::class;
        }


        public function findReductionCreditsByUser($user)
        {
                $query = $this->findByMerchantQuery() ;
                $query->andWhere('e.status = 1');
                $query->andWhere(':user MEMBER OF e.users');
                $query->setParameter('user', $user);
                return $query->getQuery()->getResult() ;
        }
}