From 73c3463e81c5188660fe84ec0164b52da15d41bb Mon Sep 17 00:00:00 2001 From: ryanldy Date: Wed, 22 May 2024 13:26:39 +0800 Subject: [PATCH] Allow disabling of scheduled prune --- README.md | 1 + config/filament-email.php | 1 + src/FilamentEmailServiceProvider.php | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 4de3de6..8c7d9e5 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ return [ 'keep_email_for_days' => 60, 'label' => null, + 'prune_enabled' => true, 'prune_crontab' => '0 0 * * *', 'can_access' => [ diff --git a/config/filament-email.php b/config/filament-email.php index b810611..d03c84e 100644 --- a/config/filament-email.php +++ b/config/filament-email.php @@ -26,6 +26,7 @@ 'keep_email_for_days' => 60, 'label' => null, + 'prune_enabled' => true, 'prune_crontab' => '0 0 * * *', 'can_access' => [ diff --git a/src/FilamentEmailServiceProvider.php b/src/FilamentEmailServiceProvider.php index a02a5f6..682a3a1 100644 --- a/src/FilamentEmailServiceProvider.php +++ b/src/FilamentEmailServiceProvider.php @@ -35,6 +35,10 @@ public function configurePackage(Package $package): void public function bootingPackage() { + if(! config('filament-email.prune_enabled')) { + return; + } + $this->callAfterResolving(Schedule::class, function (Schedule $schedule) { $runCrontab = config('filament-email.prune_crontab', '0 0 * * *'); $modelClass = config('filament-email.resource.model') ?? Email::class;