Final Roundmail system, show users with missing tips/jokers in playerlist as well.

This commit is contained in:
Torsten 2017-08-24 11:47:16 +02:00
parent 6d7ee1a47c
commit 70e28110cb
19 changed files with 3700 additions and 66 deletions

View file

@ -175,4 +175,40 @@ class Tipp extends Model
return $rStr;
}
public static function createTipps($user_id) {
$activeSeason = Season::getCurrent();
$rounds = Round::all()->where('season_id', '=', $activeSeason->id);
foreach($rounds as $round) {
$games=Game::all()->where('round_id','=',$round->id);
foreach($games as $game) {
// Tipp erzeugen wenn noch nicht vorhanden
$tipp = DB::table('tipps')->where([
['game_id','=',$game->id],
['user_id','=',$user_id]]
)->first();
if (! $tipp) {
Log::info('Creating missing tip: game_id=' . $game->id . ", user_id=" . $user->id);
$tipp=Tipp::create([
'user_id' => $user_id,
'game_id'=> $game->id,
'score1'=> -1,
'score2'=> -1,
'joker'=> false
]);
$tipp->save();
}
}
}
}
public static function createAllTips(){
$users = DB::table('users')->where('deleted',null)->get();
foreach($users as $user) {
Tipp::createTipps($user->id);
}
}
}