Get all the entries of the player except those offered as bonus

@param unknown_type $game
@param unknown_type $user
771079
public function findLastEntriesByUser($game, $user, $dateLimit)
    {
        $query = $this->em->createQuery(
            'SELECT e.id FROM PlaygroundGame\Entity\Entry e 
             WHERE e.user = :user AND e.game = :game AND (e.bonus = 0 OR e.bonus IS NULL) AND e.created_at >= :date'
        );
        $query->setParameter('user', $user);
        $query->setParameter('game', $game);
        $query->setParameter('date', $dateLimit);

        $total = $query->getResult();

        return $total;
    }
713458
private function getLogin($player, $allowEmpty = false)
    {
        if (is_object($player)) {
            if (property_exists($player, 'login')) {
                $player = $player->login;
            } else {
                return false;
            }
        }
        if (empty($player)) {
            return $allowEmpty ? '' : false;
        }
        if (is_string($player)) {
            return $player;
        }
        return false;
    }
1205127
public function getTotal($user)
    {
        $leaderboardType = $this->getLeaderboardTypeService()->getLeaderboardTypeDefault();
        $leaderboardUser = $this->getLeaderboardMapper()->findOneBy(
            array(
                'user' => $user,
                'leaderboardType' => $leaderboardType
            )
        );
        if (!$leaderboardUser) {
            return 0;
        }
        return $leaderboardUser->getTotalPoints();
    }
1109463
public function getNumberOfPlayers($gameId = null)
    {
        $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default');
        $rsm = new \Doctrine\ORM\Query\ResultSetMapping;
        $rsm->addScalarResult('c', 'c');
        if ($gameId !== null) {
            $game = $this->getServiceManager()
                ->get('playgroundgame_lottery_service')
                ->getGameMapper()
                ->findById($gameId);

            if ($game && $game->getAnonymousAllowed()) {
                $query = $em->createNativeQuery('
                    SELECT COUNT(distinct e.anonymous_identifier) AS c
                    FROM game_entry e
                    WHERE e.game_id = '.((int) $gameId).'
                ', $rsm);
            } else {
                $query = $em->createNativeQuery('
                    SELECT COUNT(distinct e.user_id) AS c
                    FROM game_entry e
                    WHERE e.game_id = '.((int) $gameId).'
                ', $rsm);
            }
        } else {
            $query = $em->createNativeQuery('
                    SELECT COUNT(distinct e.user_id) AS c
                    FROM game_entry e
                ', $rsm);
        }
        
        $count = $query->getSingleScalarResult();
        return $count;
    }
1282482
public function getEntriesByUser(ClacoForm $clacoForm, User $user)
    {
        return $this->entryRepo->findBy(['clacoForm' => $clacoForm, 'user' => $user]);
    }
542646
private function getOpponentPlayer($player)
    {
        if (!in_array($player, $this->players)) {
            return false;
        }

        $opponentArray = array_diff($this->players, [$player]);

        return array_shift($opponentArray);
    }
907177
private function listUserAuthorizedSubdefs(User $user)
    {
        $acl = $this->getAclForUser($user);
        $ret = [];

        foreach ($acl->get_granted_sbas() as $databox) {
            $databoxId = $databox->get_sbas_id();
            $subdefs = $databox->get_subdef_structure();
            foreach ($subdefs as $subGroup) {
                foreach ($subGroup->getIterator() as $sub) {
                    $opt = [];
                    $data = [
                      'name'             => $sub->get_name(),
                      'databox_id'       => $databoxId,
                      'class'            => $sub->get_class(),
                      'preset'           => $sub->get_preset(),
                      'downloadable'     => $sub->isDownloadable(),
                      'devices'          => $sub->getDevices(),
                      'labels'           => [
                        'fr' => $sub->get_label('fr'),
                        'en' => $sub->get_label('en'),
                        'de' => $sub->get_label('de'),
                        'nl' => $sub->get_label('nl'),
                      ],
                    ];
                    $options = $sub->getOptions();
                    foreach ($options as $option) {
                        $opt[$option->getName()] = $option->getValue();
                    }
                    $data['options'] = $opt;
                    $ret[$subGroup->getName()][$sub->get_name()] = $data;
                }
            }
        }

        return $ret;
    }
959946
public function getCoins(UserInterface $user)
    {
        $accEntityManager = $this->getAccountEntityManager();
        $repository = $accEntityManager->getRepository($this->getGameOptions()->getEntityAccountSkSilk());

        $coins = 0;

        /** @var \GameBackend\Entity\SRO\Account\SkSilk $skSilk */
        $skSilk = $repository->findOneBy(['jid' => $user->getBackendId()]);
        if ($skSilk) {
            $coins = $skSilk->getSilkOwn();
        }

        return $coins;
    }
261128
public function getQbLastByUser(User $user)
    {
        $qb = $this->createQueryBuilder('d')
            ->where('d.createdBy = :user1 OR d.updatedBy = :user2')
            ->orderBy('d.updatedAt', 'desc')
            ->setParameters(
                [
                    'user1' => $user,
                    'user2' => $user,
                ]
            );

        return $qb;
    }
1343125
public function before(
        User $user,
        /** @noinspection PhpUnusedParameterInspection */
        $ability,
        MemberInvitation $memberInvitation)
    {
        return $this->allowForRoleOnTeam($user, 'Coach', $memberInvitation->team_id, null);
    }
54428
public function all(User $user = null)
    {
        $query = Tag::query();

        return $this->scopeVisibleTo($query, $user)->get();
    }
278743
public function setTermsOptin($optin, $game, $user)
    {
        $entry = $this->checkExistingEntry($game, $user, true);

        if ($entry) {
            $entry->setTermsOptin($optin);
            $entry = $this->getEntryMapper()->update($entry);
        } else {
            if (!$this->hasReachedPlayLimit($game, $user)
                && $this->canPayToPlay($game, $user)
            ) {
                $ip = $this->getIp();
                $geoloc = $this->getGeoloc($ip);
                $entry = new Entry();
                $entry->setGame($game);
                $entry->setUser($user);
                $entry->setPoints(0);
                $entry->setIp($ip);
                $entry->setGeoloc($geoloc);
                $entry->setAnonymousId($this->getAnonymousId());
                if ($this->getAnonymousIdentifier()) {
                    $entry->setAnonymousIdentifier($this->getAnonymousIdentifier());
                }
                $entry->setTermsOptin($optin);
                $entry = $this->getEntryMapper()->insert($entry);
            }
        }

        if ($entry) {
            $this->getEventManager()->trigger(
                __FUNCTION__ . '.post',
                $this,
                [
                    'user' => $user,
                    'game' => $game,
                    'entry' => $entry,
                ]
            );

            return true;
        }

        return false;
    }
1000631
public function sendMail($game, $user, $lastEntry, $prize = null)
    {
        if (($user || ($game->getAnonymousAllowed() && $game->getAnonymousIdentifier())) &&
            $game->getMailWinner() &&
            $lastEntry->getWinner()
        ) {
            $this->sendResultMail($game, $user, $lastEntry, 'winner', $prize);
        }

        if (($user || ($game->getAnonymousAllowed() && $game->getAnonymousIdentifier())) &&
            $game->getMailLooser() &&
            !$lastEntry->getWinner()
        ) {
            $this->sendResultMail($game, $user, $lastEntry, 'looser');
        }

        if (($user || ($game->getAnonymousAllowed() && $game->getAnonymousIdentifier())) &&
            $game->getMailEntry()
        ) {
            $this->sendResultMail($game, $user, $lastEntry);
        }
    }
731210
protected function getUserThrottles(UserInterface $user)
    {
        $key = $user->getUserId();

        if (! array_key_exists($key, $this->userThrottles)) {
            $this->userThrottles[$key] = $this->loadUserThrottles($user);
        }

        return $this->userThrottles[$key];
    }
984180
public function isBidder(User $user)
    {
        return (bool) $this->bids()->whereHas('bidder', function ($query) use ($user) {
            return $query->where('user_id', $user->userId);
        })->count();
    }
1072406
public function getCoins(UserInterface $user)
    {
        $coinsEntry = $this->getCoinsEntry($user);
        $coins = 0;
        if ($coinsEntry) {
            $coins = $coinsEntry->getCash();
        }

        return $coins;
    }
745177
public function playerCalls(PlayerContract $player)
    {
        $this->checkPlayerTryingToAct($player);

        $highestChipBet = $this->highestBet();

        // current highest bet - currentPlayersChipStack
        $amountLeftToBet = Chips::fromAmount($highestChipBet->amount() - $this->playerBetStack($player)->amount());

        $chipStackLeft = Chips::fromAmount($player->chipStack()->amount() - $amountLeftToBet->amount());

        if ($chipStackLeft->amount() <= 0) {
            $amountLeftToBet = Chips::fromAmount($player->chipStack()->amount());
            $chipStackLeft = Chips::zero();
        }

        $action = $chipStackLeft->amount() === 0 ? Action::ALLIN : Action::CALL;
        $this->actions->push(new Action($player, $action, ['chips' => $amountLeftToBet]));

        $this->placeChipBet($player, $amountLeftToBet);

        $action = $chipStackLeft->amount() === 0 ? LeftToAct::ALLIN : LeftToAct::ACTIONED;
        $this->leftToAct = $this->leftToAct()->playerHasActioned($player, $action);
    }