Skip to content

Commit

Permalink
Update FilamentEmailServiceProvider.php
Browse files Browse the repository at this point in the history
Fixed #49
  • Loading branch information
marcogermani87 authored Apr 23, 2024
1 parent 55afb64 commit eaaa092
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/FilamentEmailServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace RickDBCN\FilamentEmail;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Support\Facades\Config;
use RickDBCN\FilamentEmail\Providers\EmailMessageServiceProvider;
use Spatie\LaravelPackageTools\Package;
use RickDBCN\FilamentEmail\Models\Email;
use Illuminate\Console\Scheduling\Schedule;
use Spatie\LaravelPackageTools\PackageServiceProvider;
use RickDBCN\FilamentEmail\Providers\EmailMessageServiceProvider;

class FilamentEmailServiceProvider extends PackageServiceProvider
{
Expand All @@ -32,9 +33,10 @@ public function configurePackage(Package $package): void
public function bootingPackage()
{
$this->callAfterResolving(Schedule::class, function (Schedule $schedule) {
$class = get_class(new (Config::get('filament-email.resource.model')));
$modelClass = Config::get('filament-email.resource.model') ?? Email::class;
$class = get_class(new $modelClass);
if (class_exists($class)) {
$schedule->command('model:prune --model="'.$class.'"')->daily();
$schedule->command('model:prune --model="' . $class . '"')->daily();
}
});
}
Expand Down

0 comments on commit eaaa092

Please sign in to comment.