Skip to content

Commit

Permalink
Optimized PR #63. Updated README.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcogermani87 committed May 27, 2024
1 parent c2b1f38 commit 08b864c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
Expand Down
2 changes: 2 additions & 0 deletions config/filament-email.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
],

'keep_email_for_days' => 60,

'label' => null,

'prune_enabled' => true,

'prune_crontab' => '0 0 * * *',

'can_access' => [
Expand Down
24 changes: 12 additions & 12 deletions src/FilamentEmailServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}
}
}

0 comments on commit 08b864c

Please sign in to comment.