diff --git a/README.md b/README.md index 8c7d9e5..714be57 100644 --- a/README.md +++ b/README.md @@ -79,15 +79,17 @@ return [ ], 'keep_email_for_days' => 60, + 'label' => null, 'prune_enabled' => true, + 'prune_crontab' => '0 0 * * *', 'can_access' => [ 'role' => [], ], - + 'pagination_page_options' => [ 10, 25, 50, 'all', ], diff --git a/config/filament-email.php b/config/filament-email.php index d03c84e..aa28db0 100644 --- a/config/filament-email.php +++ b/config/filament-email.php @@ -24,9 +24,11 @@ ], '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 dbf4001..ee1523a 100644 --- a/src/FilamentEmailServiceProvider.php +++ b/src/FilamentEmailServiceProvider.php @@ -35,18 +35,18 @@ public function configurePackage(Package $package): void public function bootingPackage() { - if (! config('filament-email.prune_enabled')) { - return; - } + $pruneEnabled = config('filament-email.prune_enabled') ?? false; - $this->callAfterResolving(Schedule::class, function (Schedule $schedule) { - $runCrontab = config('filament-email.prune_crontab', '0 0 * * *'); - $modelClass = config('filament-email.resource.model') ?? Email::class; - $class = get_class(new $modelClass); - if (class_exists($class)) { - $schedule->command('model:prune --model="'.$class.'"') - ->cron($runCrontab); - } - }); + if ($pruneEnabled) { + $this->callAfterResolving(Schedule::class, function (Schedule $schedule) { + $runCrontab = config('filament-email.prune_crontab', '0 0 * * *'); + $modelClass = config('filament-email.resource.model') ?? Email::class; + $class = get_class(new $modelClass); + if (class_exists($class)) { + $schedule->command('model:prune --model="' . $class . '"') + ->cron($runCrontab); + } + }); + } } }