-
-
Save kasparasg/ac775991302341f80bb445241fd57da7 to your computer and use it in GitHub Desktop.
Revisions
-
davidpiesse revised this gist
Feb 27, 2018 . No changes.There are no files selected for viewing
-
davidpiesse renamed this gist
Feb 27, 2018 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,13 @@ <?php //Don't forget to change the namespace! namespace App\Traits; use Cron\CronExpression; use Illuminate\Support\Carbon; use Illuminate\Console\Scheduling\ManagesFrequencies; trait Schedulable{ use ManagesFrequencies; -
davidpiesse created this gist
Feb 21, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ <?php namespace App\Traits; use Cron\CronExpression; use Illuminate\Support\Carbon; use Illuminate\Console\Scheduling\ManagesFrequencies; trait HasSchedule{ use ManagesFrequencies; protected $expression = '* * * * *'; protected $timezone; public function isDue(){ $date = Carbon::now(); if ($this->timezone) { $date->setTimezone($this->timezone); } return CronExpression::factory($this->expression)->isDue($date->toDateTimeString()); } public function nextDue(){ return Carbon::instance(CronExpression::factory($this->expression)->getNextRunDate()); } public function lastDue(){ return Carbon::instance(CronExpression::factory($this->expression)->getPreviousRunDate()); } }