public function getTeam(\Club\MatchBundle\Entity\League $league, \Club\MatchBundle\Entity\Team $team)
 {
     $lt = $this->_em->getRepository('ClubMatchBundle:LeagueTable')->findOneBy(array('league' => $league->getId(), 'team' => $team->getId()));
     if (!$lt) {
         $lt = $this->addTeam($league, $team);
     }
     return $lt;
 }
 public function getUsersBySearch(\Club\MatchBundle\Entity\League $league, $query)
 {
     return $this->_em->createQueryBuilder()->select(array('l', 'u'))->from('ClubMatchBundle:League', 'l')->leftJoin('l.users', 'u')->leftJoin('u.profile', 'p')->where('l.id = :league')->andWhere("u.member_number = :number OR CONCAT(CONCAT(p.first_name,' '), p.last_name) LIKE :query")->setParameter('league', $league->getId())->setParameter('number', $query)->setParameter('query', '%' . $query . '%')->getQuery()->getOneOrNullResult();
 }