26 lines
716 B
PHP
26 lines
716 B
PHP
|
<?php
|
||
|
require_once "../../../bootstrap.php";
|
||
|
require_once "../Admin/Admin.php";
|
||
|
use Backend\Models\Group;
|
||
|
use Backend\Models\Vote;
|
||
|
|
||
|
if(isAdmin() && isset($_GET['gameJamId'])){
|
||
|
$groups = Group::where('game_jam_id',$_GET['gameJamId'])->get();
|
||
|
$winningGroup = array();
|
||
|
$i = -1;
|
||
|
foreach ($groups as $group){
|
||
|
$x = Vote::where('group_id', $group->id)->count();
|
||
|
if($x>$i){
|
||
|
$winningGroup = array();
|
||
|
array_push($winningGroup,$group);
|
||
|
$i = $x;
|
||
|
}
|
||
|
elseif ($i === $x){
|
||
|
array_push($winningGroup,$group);
|
||
|
}
|
||
|
}
|
||
|
header('Content-Type: application/json;charset=UTF-8');
|
||
|
echo $winningGroup->toJson(JSON_PRETTY_PRINT);
|
||
|
}
|
||
|
|