Get won bets - PHP Laravel Betting Site -
i'm building betting website using laravel 5. can place singlebet(a bet containing 1 game only) or multibet(a bet containing several games).
i want if game over, reward users based on correct predictions.
i have several tables, these relevant question.
**games table** id, team1, team2 1, arsenal, chelsea 2, everton, machester city 3, swansea, stoke **bets table** id, game_id, random_code,stake,choice, won, settled 1, 1, xyz123, 1000, 1, 1, 1 2, 2, xyz123, 1000, 2, 0, 0 3, 1, sdx132, 500, 1, 1, 1
as can see on bets table, first 2 records makes multibet(because placed @ same time, hence same random code), while third row single bet. stake refers amount has placed. choice 1 => home win, 2 => away win, 3 => draw. won boolean set when enter results. 1 means bet won, 0 lost bet. settled boolean show if results game_id has been posted.
my problem how determine won bets. example, how check single bet has been won , bet singlebet , if multibet, have other bets settled , won too?
i'm using laravel 5 , here sample code:
public function rewardusers() { $allbets = bet::where('won', true)->where('settled', true)->get(); if(count($allbets) == 1) { echo 'singlebet'; } elseif(count($allbets) > 1) { echo 'multibet'; } else { echo "ignore"; } }
i hope i'm clear , volunteer me.
thanks
Comments
Post a Comment