Working in Liga Auf/Abstieg
This commit is contained in:
parent
0d690560ab
commit
444ce18f63
4 changed files with 115 additions and 4 deletions
60
pfosten/app/Test.php
Normal file
60
pfosten/app/Test.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Test extends Model
|
||||
{
|
||||
// In order for testing seasons to work, we need a way to set all the users to 'paid'
|
||||
public static function paySeason($seasonId)
|
||||
{
|
||||
$users = User::all();
|
||||
$cnt=0;
|
||||
foreach ($users as $user) {
|
||||
Payment::set_payment_date($user->id, $seasonId, '01.01.2017');
|
||||
$cnt+=1;
|
||||
}
|
||||
return $cnt." Users in season_id ".$seasonId." set to paid";
|
||||
}
|
||||
|
||||
public static function fillSeason($seasonId) {
|
||||
error_log("creating all tipps started");
|
||||
Tipp::createAllTips();
|
||||
error_log("creating all tipps completed");
|
||||
$users = User::all();
|
||||
|
||||
error_log("setting payment started");
|
||||
Test::paySeason($seasonId);
|
||||
error_log("setting payment completed");
|
||||
|
||||
|
||||
error_log("Users: ".sizeof($users));
|
||||
|
||||
// Spielergebnisse faken
|
||||
$rounds=Round::where('season_id','=',$seasonId)->get();
|
||||
error_log("Rounds: ".sizeof($rounds));
|
||||
foreach ($rounds as $round) {
|
||||
$games=Game::where('round_id','=',$round->id)->get();
|
||||
$jokerSet=false;
|
||||
error_log("Faking Tipps and game results for all users for: ".$round->name);
|
||||
foreach ($games as $game) {
|
||||
$game->score1=random_int(0,3);
|
||||
$game->score2=random_int(0,3);
|
||||
$game->save();
|
||||
foreach ($users as $user) {
|
||||
// Tipps faken
|
||||
$tipp=Tipp::where('game_id','=',$game->id)->where('user_id','=',$user->id)->first();
|
||||
$tipp->score1 = random_int(0,3);
|
||||
$tipp->score2 = random_int(0,3);
|
||||
if (!$jokerSet) {
|
||||
$tipp->joker=true;
|
||||
}
|
||||
$tipp->save();
|
||||
}
|
||||
$jokerSet=true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue