diff --git a/pfosten/app/Http/Controllers/UsersController.php b/pfosten/app/Http/Controllers/UsersController.php index 50d6295b..5de1118c 100755 --- a/pfosten/app/Http/Controllers/UsersController.php +++ b/pfosten/app/Http/Controllers/UsersController.php @@ -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); + } + } + + } diff --git a/pfosten/app/Round.php b/pfosten/app/Round.php index 5fa64c35..1eee0fc0 100755 --- a/pfosten/app/Round.php +++ b/pfosten/app/Round.php @@ -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(); diff --git a/pfosten/app/User.php b/pfosten/app/User.php index b331295b..6b960105 100644 --- a/pfosten/app/User.php +++ b/pfosten/app/User.php @@ -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; + } + } diff --git a/pfosten/config/mail.php b/pfosten/config/mail.php index bb92224c..29cd7be7 100644 --- a/pfosten/config/mail.php +++ b/pfosten/config/mail.php @@ -56,8 +56,8 @@ return [ */ 'from' => [ - 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), - 'name' => env('MAIL_FROM_NAME', 'Example'), + 'address' => env('MAIL_FROM_ADDRESS', 'info@hoschis-tippspiel.de'), + 'name' => env('MAIL_FROM_NAME', 'Hoschis Tippspiel'), ], /* diff --git a/pfosten/database/migrations/2017_08_16_164654_create_quotas_table.php b/pfosten/database/migrations/2017_08_16_164654_create_quotas_table.php index d820b5c0..87a539c0 100644 --- a/pfosten/database/migrations/2017_08_16_164654_create_quotas_table.php +++ b/pfosten/database/migrations/2017_08_16_164654_create_quotas_table.php @@ -16,14 +16,11 @@ class CreateQuotasTable extends Migration Schema::create('quotas', function (Blueprint $table) { $table->increments('id'); - $table->integer('season_id'); - $table->string('qtype',100); + $table->integer('season_id')->default(0); $table->string('name',100); - $table->integer('order')->default(1); + $table->integer('order')->default(0); $table->integer('prc')->default(0); - - $table->timestamps(); }); } diff --git a/pfosten/resources/views/emails/roundmail.blade.php b/pfosten/resources/views/emails/roundmail.blade.php new file mode 100644 index 00000000..7c17878b --- /dev/null +++ b/pfosten/resources/views/emails/roundmail.blade.php @@ -0,0 +1,19 @@ + + +
+ ++
+
+
{{ $roundname }}
-{!! $report !!}
- -+ +
+ + + + + + + + + + + + + + + +