Exemplo n.º 1
0
 public static function checkExpired()
 {
     $expired = Bet::available()->where('expires_at', '<=', date('Y-m-d H:i:s'))->whereNull('accepted_by_user_id')->lists('id');
     if (count($expired) > 0) {
         Bet::whereIn('id', $expired)->update(array('expired' => 1));
     }
     $finished = Bet::where('expires_at', '<=', date('Y-m-d H:i:s'))->whereNotNull('accepted_by_user_id')->where('winner_paid', 0)->get();
     foreach ($finished as $bet) {
         $bet->handleWinner();
     }
 }
Exemplo n.º 2
0
 public function getBets()
 {
     if (!Auth::check()) {
         App::abort(404);
     }
     $bets = Auth::user()->bets()->lists('id');
     $cross_bets = Auth::user()->crossBets()->lists('id');
     if (count($bets) || count($cross_bets)) {
         $bets = Bet::whereIn('id', array_merge($bets, $cross_bets))->orderBy('expires_at', 'asc')->get();
     } else {
         $bets = array();
     }
     return View::make('users.bets', compact('bets'));
 }