/
home
/
obinna
/
html
/
boaz2
/
src
/
Repository
/
Upload File
HOME
<?php namespace App\Repository; use App\Entity\UserDepot; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; /** * @method UserDepot|null find($id, $lockMode = null, $lockVersion = null) * @method UserDepot|null findOneBy(array $criteria, array $orderBy = null) * @method UserDepot[] findAll() * @method UserDepot[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class UserDepotRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, UserDepot::class); } // /** // * @return UserDepot[] Returns an array of UserDepot objects // */ public function findByExampleField($user) { return $this->createQueryBuilder('ud') ->andWhere('ud.user = :user') ->setParameter('user', $user) ->orderBy('u.id', 'ASC') ->setMaxResults(10) ->getQuery() ->getResult() ; } public function findNotCheckedIn($user) { return $this->getEntityManager() ->createQuery( 'SELECT ud FROM App\Entity\UserDepot ud WHERE ud.user = :user AND (ud.checkout IS NULL)' )->setParameter('user', $user) ->getResult(); } public function findNonCheckedOut($user) { $close = new \DateTime('today 00:00'); return $this->getEntityManager() ->createQuery( 'SELECT d.id, d.name FROM App\Entity\UserDepot ud, App\Entity\Depot d WHERE d = ud.depot AND ud.user = :user AND (ud.checkout IS NULL)' )->setParameter('user', $user) ->getResult(); } public function findNonCheckedOutAll() { $cutoff = new \DateTime('today 00:00'); return $this->getEntityManager() ->createQuery( 'SELECT ud.id FROM App\Entity\UserDepot ud WHERE ud.checkout IS NULL AND ud.checkin < :cutoff' )->setParameter('cutoff', $cutoff) ->getResult(); } public function findCheckedInUser($depot) { $start = new \DateTime('today 06:00'); $end = new \DateTime('today 20:00'); return $this->getEntityManager() ->createQuery( 'SELECT u.telephone, u.email FROM App\Entity\UserDepot ud, App\Entity\User u WHERE IDENTITY(ud.user) = u.id AND IDENTITY(ud.depot) = :depot AND ud.checkout IS NULL AND ud.checkin > :start AND ud.checkin < :end' )->setParameter('start', $start) ->setParameter('end', $end) ->setParameter('depot', $depot->getId()) ->getResult(); } /* public function findOneBySomeField($value): ?UserDepot { return $this->createQueryBuilder('u') ->andWhere('u.exampleField = :val') ->setParameter('val', $value) ->getQuery() ->getOneOrNullResult() ; } */ }