2017-10-11 11:14:23 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
2017-11-02 16:41:07 +01:00
|
|
|
use Carbon;
|
2017-10-11 11:14:23 +02:00
|
|
|
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'
|
2017-11-02 16:41:07 +01:00
|
|
|
// this method is used by fillSeason method
|
2017-12-29 19:08:46 +01:00
|
|
|
public static function paySeason($seasonId=-1)
|
2017-10-11 11:14:23 +02:00
|
|
|
{
|
2017-12-29 19:08:46 +01:00
|
|
|
if ($seasonId==-1) {
|
|
|
|
|
$season = Season::getCurrent();
|
|
|
|
|
$seasonId = $season->id;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-11 11:14:23 +02:00
|
|
|
$users = User::all();
|
|
|
|
|
$cnt=0;
|
|
|
|
|
foreach ($users as $user) {
|
2018-01-01 18:25:56 +01:00
|
|
|
if (!$user->deleted && $user->id !=1)
|
2017-11-30 11:07:27 +01:00
|
|
|
{ Payment::set_payment_date($user->id, $seasonId, '01.01.2017'); $cnt+=1;}
|
|
|
|
|
|
2017-10-11 11:14:23 +02:00
|
|
|
}
|
|
|
|
|
return $cnt." Users in season_id ".$seasonId." set to paid";
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-02 16:41:07 +01:00
|
|
|
public static function fillSeason($seasonId=-1) {
|
2017-12-29 19:08:46 +01:00
|
|
|
if ($seasonId==-1) {
|
|
|
|
|
$season = Season::getCurrent();
|
|
|
|
|
$seasonId = $season->id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-10-11 11:14:23 +02:00
|
|
|
error_log("creating all tipps started");
|
|
|
|
|
Tipp::createAllTips();
|
|
|
|
|
error_log("creating all tipps completed");
|
|
|
|
|
$users = User::all();
|
|
|
|
|
|
2017-11-02 16:41:07 +01:00
|
|
|
|
2017-12-29 19:08:46 +01:00
|
|
|
|
2017-11-02 16:41:07 +01:00
|
|
|
|
2017-10-11 11:14:23 +02:00
|
|
|
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);
|
2017-11-02 16:41:07 +01:00
|
|
|
$game->kickoff= Carbon\Carbon::now();
|
2017-10-11 11:14:23 +02:00
|
|
|
$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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|