public function winner()
 {
     if ($this->winner_id != null) {
         $winner = Player::find($this->winner_id);
         return $winner->user;
     } else {
         return null;
     }
 }
Exemplo n.º 2
0
 public function finalize()
 {
     switch ($this->type) {
         case BidPackage::BIDCOIN_TYPE:
             // Bid coin order
             $player = Player::find($this->player_id);
             if ($player->creditBidCoins($this->quantity)) {
                 $this->status = self::ORDER_PAID;
                 $this->save();
                 return true;
             } else {
                 return false;
             }
             break;
     }
 }
 /**
  * @param $playerId
  * @param $auctionId
  * @throws \Exception
  */
 public function sendBid($playerId, $auctionId)
 {
     $player = Player::find($playerId);
     $auction = Auction::find($auctionId);
     try {
         $this->setLiveAuctionData($auction->acceptBid($player));
     } catch (\Exception $ex) {
         $this->setLiveAuctionData($auction);
         throw $ex;
     }
 }
 public function findPlayer($player_id)
 {
     return Player::find($player_id);
 }
Exemplo n.º 5
0
 private function bindPlayer()
 {
     $player = Player::where('user_id', $this->id)->first();
     $this->bid_coins = number_format($player->bid_coins);
     $this->player_id = $player->id;
 }