Start of Test Class, fixing ranking visibiliy of open rounds issue
This commit is contained in:
parent
7545760aa2
commit
29e493e22d
11 changed files with 11891 additions and 43 deletions
|
|
@ -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("/"); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue