Start of Test Class, fixing ranking visibiliy of open rounds issue

This commit is contained in:
Torsten 2017-10-06 12:17:49 +02:00
parent 7545760aa2
commit 29e493e22d
11 changed files with 11891 additions and 43 deletions

View file

@ -171,32 +171,28 @@ class LeaguesController extends Controller
return redirect("/seasons");
}
public function showLeagueRounds($league_rank, $maxRoundId) {
public function showLeagueRounds($league_rank) {
if (Auth::guest()) { return redirect("/"); }
$season=Season::getCurrent();
$maxRoundId = min(Round::getLastRoundId($season->id),$maxRoundId);
$roundNames = Round::getNames();
$leagueNames = League::getNames();
$leagues = League::where('season_id','=',$season->id)->where('rank','=', $league_rank)->orderBy('id')->get();
$matchesTotal = array();
foreach ($leagues as $league) {
$matches = Match::getMatchResults($league->id, $maxRoundId);
$matches = Match::getMatchResults($league->id, -1);
foreach ($matches as $match) {
if ($match->round_id <= $maxRoundId) {
if (!key_exists($match->round_id, $matchesTotal)) {
$matchesTotal[$match->round_id]=array();
}
if (!key_exists($league->id, $matchesTotal[$match->round_id] )) {
$matchesTotal[$match->round_id][$league->id]=array();
}
$lg = $matchesTotal[$match->round_id][$league->id];
array_push($lg, $match);
$matchesTotal[$match->round_id][$league->id] = $lg;
if (!key_exists($match->round_id, $matchesTotal)) {
$matchesTotal[$match->round_id]=array();
}
if (!key_exists($league->id, $matchesTotal[$match->round_id] )) {
$matchesTotal[$match->round_id][$league->id]=array();
}
$lg = $matchesTotal[$match->round_id][$league->id];
array_push($lg, $match);
$matchesTotal[$match->round_id][$league->id] = $lg;
}
}

View file

@ -4,8 +4,12 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Season;
use App\Round;
use App\Quota;
use App\User;
use App\Game;
use App\Tipp;
use Carbon;
use DB;
use Auth;
use Log;
@ -49,25 +53,81 @@ class SeasonsController extends Controller
// Validate form
$this->validate(request(), [
'name' => 'required'
'name' => 'required',
'roundcount' => 'required'
]);
// Create and save the season
$season = Season::create([
'name' => request('name')
'name' => request('name'),
'rounds' => request('roundcount')
]);
if (Season::all()->count()==1) {
Season::setCurrent($season->id);
Log::info('Setting season id=' .$season->id);
}
$season->save();
Season::setCurrent($season->id);
Log::info('Setting season id=' .$season->id);
Quota::createDefaultQuota($season->id);
$nr=1;
$roundcount=request('roundcount');
$seasonId = Season::getCurrent()->id;
$endOfYear = Carbon\Carbon::createFromDate(Carbon\Carbon::now()->year,12,31);
while($nr<=$roundcount) {
$roundname="Runde ".$nr;
Log::info("Creating: ".$roundname);
$round = Round::create([
'name' => $roundname,
'season_id' => $seasonId
]);
$round->save();
$round_id = $round->id;
$game1 = Game::create([
'round_id' => $round_id,
'team1' => "Mannschaft 1",
'team2' => "Mannschaft 2",
//'kickoff' => User::toDBDate(request('game1_kickoff'))
'kickoff' => $endOfYear
]);
$game1->save();
$game2 = Game::create([
'round_id' => $round_id,
'team1' => "Mannschaft 3",
'team2' => "Mannschaft 4",
'kickoff' => $endOfYear
]);
$game2->save();
$game3 = Game::create([
'round_id' => $round_id,
'team1' => "Mannschaft 5",
'team2' => "Mannschaft 6",
'kickoff' => $endOfYear
]);
$game3->save();
$game4 = Game::create([
'round_id' => $round_id,
'team1' => "Mannschaft 7",
'team2' => "Mannschaft 8",
'kickoff' => $endOfYear
]);
$game4->save();
// Sign them in
$nr+=1;
}
Log::info("Round creation completed, now setting Tipps");
Tipp::createAllTips();
// Redirect to the home page
return redirect('/seasons');
}
public function store_quota() {
if (Auth::guest()) { return redirect("/"); }
if (!Auth::user()->admin) { return redirect("/"); }

View file

@ -193,6 +193,7 @@ class UsersController extends Controller
$currentSeason = Season::getCurrent();
// Check ob mindestens eine Runde der Saison gelockt ist angezeigt werden kann
if($max_round_id==-1) {
$max_round_id = Round::getLastLockedRoundId();
if ($max_round_id==-1) {
@ -209,6 +210,10 @@ class UsersController extends Controller
}
}
$max_round_id=min($max_round_id, Round::getLastLockedRoundId());
// Payment made ?
if (! User::payment_date(Auth::user()->id, $currentSeason->id) && Auth::user()->name!="Torsten Schneider") {
return view('users.no_payment');
@ -428,7 +433,6 @@ class UsersController extends Controller
]);
$user=Auth::user();
$user->email=request('email');
@ -455,6 +459,7 @@ class UsersController extends Controller
public function money_ranking() {
if (Auth::guest()) { return redirect("/"); }
$currentSeason = Season::getCurrent();
// Payment made ?
@ -474,15 +479,6 @@ class UsersController extends Controller
foreach($user_ids as $user_id) {
$key=$round_id."_".$user_id;
if ($key=='13_44') {
Log::info("Debat(44) Debug");
Log::info("is_dayscorewinner:");
Log::info($roundtipps[$key]['is_dayscorewinner']);
Log::info("payout:");
Log::info($roundtipps[$key]['payout']);
}
$payout = str_replace(",",".",$roundtipps[$key]['payout']);
if (strlen($payout)==0) { $payout=0; }