| Conditions | 5 |
| Paths | 5 |
| Total Lines | 25 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php namespace GolfLeague\Services; |
||
| 10 | public function calculate() |
||
| 11 | { |
||
| 12 | $levels = Level::all(); |
||
| 13 | $matches = Match::all(); |
||
| 14 | $carryOverMoney = array(); |
||
| 15 | foreach ($levels as $key => $level){ |
||
| 16 | $carryOverMoney[$level->id] = 0; |
||
| 17 | foreach($matches as $matchesKey => $match) { |
||
| 18 | //check skins table for level and match |
||
| 19 | $skins = Skin::where('match_id', '=', $match->id)->where('level_id', '=', $level->id)->get(); |
||
| 20 | if($skins->count() === 0 ) { |
||
| 21 | if ($level->id === 1){ |
||
| 22 | $carryOverMoney[$level->id] += $match->skinsamoney; |
||
| 23 | } |
||
| 24 | else { |
||
| 25 | $carryOverMoney[$level->id] += $match->skinsbmoney; |
||
| 26 | } |
||
| 27 | } |
||
| 28 | else { |
||
| 29 | $carryOverMoney[$level->id] = 0; //reset carryover money |
||
| 30 | } |
||
| 31 | } |
||
| 32 | }// End foreach |
||
| 33 | return $carryOverMoney; |
||
| 34 | } |
||
| 35 | } |