Working on Roundmail system
This commit is contained in:
parent
3fa31921f0
commit
6d7ee1a47c
11 changed files with 224 additions and 24 deletions
|
|
@ -10,9 +10,12 @@ use App\Round;
|
|||
use App\Game;
|
||||
use App\Tipp;
|
||||
use App\Quota;
|
||||
use App\Mail\Roundmail;
|
||||
|
||||
use DB;
|
||||
use Auth;
|
||||
use Log;
|
||||
|
||||
use Carbon;
|
||||
|
||||
class UsersController extends Controller
|
||||
|
|
@ -23,17 +26,25 @@ class UsersController extends Controller
|
|||
|
||||
$currentSeason=Season::getCurrent();
|
||||
|
||||
$display_rounds=array();
|
||||
if ($currentSeason) {
|
||||
$round_id = Round::getLastCompleteRoundId();
|
||||
|
||||
if ($round_id > -1) {
|
||||
$round = Round::where("id", "=", $round_id)->first();
|
||||
$report = $round->report;
|
||||
$rounds = Round::where("id", "<=", $round_id)->get();
|
||||
foreach($rounds as $round) {
|
||||
$dpr =array();
|
||||
$dpr["name"]=$round->name;
|
||||
$dpr["report"]=$round->report;
|
||||
array_push($display_rounds, $dpr);
|
||||
}
|
||||
$display_rounds = array_reverse($display_rounds);
|
||||
Log::info("Loaded report:".$report." round-id=".$round_id);
|
||||
$roundname = $round->name;
|
||||
} else { Log::info("No round identified. Last Locked=".$round_id); $report="";}
|
||||
} else {Log::info("No current season");}
|
||||
|
||||
return view('main',compact('roundname','report'));
|
||||
return view('main',compact('roundname','display_rounds'));
|
||||
}
|
||||
|
||||
public function index() {
|
||||
|
|
@ -392,4 +403,17 @@ class UsersController extends Controller
|
|||
return view('users.show_payouts', compact('payouts','active_user_count','einsatz','currentSeason'));
|
||||
}
|
||||
|
||||
public function mailtest() {
|
||||
// Works:
|
||||
// $user = User::where('id','=',1)->first();
|
||||
// \Mail::to($user)->send(new Roundmail);
|
||||
|
||||
$users = User::whereIn('id',array(1,2,7,57))->get();
|
||||
foreach($users as $user) {
|
||||
Log::info("Sending Roundmail to: ".$user->name);
|
||||
\Mail::to($user)->send(new Roundmail);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,21 @@ class Round extends Model
|
|||
return $lastCompleteRound;
|
||||
}
|
||||
|
||||
public static function getFirstIncompleteRound() {
|
||||
$season_id = Season::getCurrent()->id;
|
||||
$rounds = Round::where('season_id','=',$season_id)->orderBy('id')->get();
|
||||
foreach($rounds as $round) {
|
||||
$games = Game::where('round_id','=',$round->id);
|
||||
foreach ($games as $game) {
|
||||
if ($game->score1 == -1 || $game->score2 == -1) {
|
||||
return $round->id;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static function getLastLockedRoundId() {
|
||||
$season = Season::getCurrent();
|
||||
$rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get();
|
||||
|
|
|
|||
|
|
@ -130,7 +130,34 @@ class User extends Authenticatable
|
|||
return $dbDate;
|
||||
}
|
||||
|
||||
public function hello() {
|
||||
return "Hello";
|
||||
public static function hasMissingTipp($user_id) {
|
||||
$round_id = Round::getFirstIncompleteRound();
|
||||
$games = Game::where('round_id','=',$round_id);
|
||||
|
||||
foreach ($games as $game) {
|
||||
$tipp = Tipp::where('game_id','=',$game->id)->first();
|
||||
|
||||
if ($tipp->score1 == -1 || $tipp->score2 == -1) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function hasMissingJoker($user_id) {
|
||||
$round_id = Round::getFirstIncompleteRound();
|
||||
$games = Game::where('round_id','=',$round_id);
|
||||
|
||||
$joker=0;
|
||||
foreach ($games as $game) {
|
||||
$tipp = Tipp::where('game_id','=',$game->id)->first();
|
||||
if ($tipp->joker == true) { $joker=1; }
|
||||
}
|
||||
|
||||
if ($joker==1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue