Roundmail::checkReminder automailing system

This commit is contained in:
Torsten 2017-08-28 16:34:19 +02:00
parent 6aad1a7ab2
commit 1f5e056b7f
18 changed files with 269 additions and 116 deletions

View file

@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model;
use App\Game;
use Log;
use DB;
use Carbon;
class Round extends Model
{
@ -31,8 +32,6 @@ class Round extends Model
return false;
}
public static function isCompleted($round_id) {
$round = Round::where('id','=',$round_id)->first();
$games = Game::where('round_id','=',$round->id)->get();
@ -99,4 +98,39 @@ class Round extends Model
return $result[0]->round_id;
}
public static function getTippSpielLink() // Mit Verweis auf den aktuellen Tipp
{
$firstTippableRoundId=Round::getFirstTippableRound()->id;
$tippSpielLink="http://hoschis-tippspiel.de/tipps#".$firstTippableRoundId;
return $tippSpielLink;
}
// Ab sofort Verzicht auf statische Methoden, soweit möglich.
public function getLockTime() {
$games = Game::where('round_id','=',$this->id)->get();
$earliestKickoff = Carbon\Carbon::now();
$earliestKickoff->addWeeks(100);
foreach($games as $game) {
$kickoff = Carbon\Carbon::parse($game->kickoff);
if ($kickoff < $earliestKickoff) { $earliestKickoff = $kickoff; }
}
$earliestKickoff->subHour();
return $earliestKickoff;
}
public function isInLockWarningTime($hours) {
$hourDiffToLock=$this->getLockTime()->diffInHours(Carbon\Carbon::now());
if ($hourDiffToLock<=$hours) return true;
return false;
}
public function getRemainingHoursBeforeLock() {
$hourDiffToLock=$this->getLockTime()->diffInHours(Carbon\Carbon::now());
return $hourDiffToLock;
}
}