Skip to content

Commit 4e48f11

Browse files
committed
Use the model class for scheduler manager.
1 parent bec9a15 commit 4e48f11

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/SchedulerManager.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@
33
namespace Binarcode\LaravelMailator;
44

55
use Binarcode\LaravelMailator\Models\MailatorSchedule;
6+
use Binarcode\LaravelMailator\Support\ClassResolver;
67

78
class SchedulerManager
89
{
10+
use ClassResolver;
11+
912
private ?MailatorSchedule $instance;
1013

1114
public function init(string $name): MailatorSchedule
1215
{
13-
return $this->instance = MailatorSchedule::init($name);
16+
return $this->instance = (static::scheduler())::init($name);
1417
}
1518

1619
public function __destruct()
1720
{
18-
if (! $this->instance->wasRecentlyCreated) {
21+
if (!$this->instance->wasRecentlyCreated) {
1922
$this->instance->save();
2023
}
2124
}

src/Support/ClassResolver.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Binarcode\LaravelMailator\Support;
44

55
use Binarcode\LaravelMailator\Actions\ResolveGarbageAction;
6+
use Binarcode\LaravelMailator\Models\MailatorSchedule;
67

78
trait ClassResolver
89
{
@@ -12,4 +13,11 @@ public static function garbageResolver(): ResolveGarbageAction
1213
config('mailator.scheduler.garbage_resolver', ResolveGarbageAction::class),
1314
);
1415
}
16+
17+
public static function scheduler(): MailatorSchedule
18+
{
19+
return app(
20+
config('mailator.scheduler.model', MailatorSchedule::class),
21+
);
22+
}
1523
}

0 commit comments

Comments
 (0)