GShirt: Started working on Tipp::gshirt_table()
This commit is contained in:
parent
a41157ea5b
commit
dbc687ee55
4 changed files with 71 additions and 0 deletions
|
|
@ -573,4 +573,14 @@ class UsersController extends Controller
|
|||
|
||||
return view ('users.payout_ranking_detail',compact('payouts','user'));
|
||||
}
|
||||
|
||||
public function gshirt_ranking() {
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
|
||||
|
||||
|
||||
|
||||
return view ('users.gshirt_ranking');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -692,4 +692,36 @@ class Tipp extends Model
|
|||
public static function cmpGShirt($rank1, $rank2) {
|
||||
return ($rank1[1] < $rank2[1]); //Feld0: user_id, Feld1: rank
|
||||
}
|
||||
|
||||
//Used by gshirt_table: sort by gshirt_totalscore
|
||||
public static function cmpGShirtTotal($ranktippEntry1, $ranktippEntry2) {
|
||||
return ($ranktippEntry1['gshirt_totalscore'] < $ranktippEntry2['gshirt_totalscore']); //Feld0: user_id, Feld1: rank
|
||||
}
|
||||
|
||||
public static function gshirt_table() {
|
||||
$rt = Tipp::getRoundTipps();
|
||||
$roundtipps = $rt['roundtipps'];
|
||||
$round_ids = $rt['round_ids'];
|
||||
$last_round_id = end($round_ids);
|
||||
$users=User::getActives();
|
||||
|
||||
$lastroundentries=array();
|
||||
foreach ($users as $user) {
|
||||
$key=$last_round_id."_".$user->id;
|
||||
array_push($lastroundentries, $roundtipps[$key]);
|
||||
}
|
||||
usort($lastroundentries, array('App\Tipp', 'cmpGShirtTotal'));
|
||||
|
||||
$displayRanking=array();
|
||||
foreach($lastroundentries as $entry) {
|
||||
$user_id = $entry['user_id'];
|
||||
$displayRanking[$user_id]=array();
|
||||
foreach ($round_ids as $round_id) {
|
||||
$key = $round_id."_".$user_id;
|
||||
array_push($displayRanking[$user_id],$roundtipps[$key]);
|
||||
}
|
||||
}
|
||||
// TO BE CONTINUED...
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue