-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add hour precision when mailator is dispached
- Loading branch information
Vasile Papuc
committed
Jun 27, 2023
1 parent
7c3fa06
commit a7cf486
Showing
10 changed files
with
174 additions
and
35 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
database/migrations/alter_table_mailator_schedule_at_hours_column.php.stub
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
use Binarcode\LaravelMailator\Models\MailatorLog; | ||
use Binarcode\LaravelMailator\Models\MailatorSchedule; | ||
|
||
class AlterSchedulerAtHoursColumnTables extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::table(config('mailator.schedulers_table_name', 'mailator_schedulers'), function (Blueprint $table) { | ||
$table->json('schedule_at_hours')->nullable()->after('last_sent_at'); | ||
}); | ||
} | ||
} |
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Binarcode\LaravelMailator\Constraints; | ||
|
||
use Binarcode\LaravelMailator\Models\MailatorLog; | ||
use Binarcode\LaravelMailator\Models\MailatorSchedule; | ||
use Carbon\Carbon; | ||
use Illuminate\Support\Collection; | ||
|
||
class HoursSchedulerCheckerConstraint implements SendScheduleConstraint | ||
{ | ||
public function canSend(MailatorSchedule $schedule, Collection $logs): bool | ||
{ | ||
if (!$schedule->hasPrecision()) { | ||
return true; | ||
} | ||
|
||
return in_array(now()->hour, $schedule->schedule_at_hours); | ||
} | ||
} |
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Oops, something went wrong.