-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathModelExpiresServiceProvider.php
42 lines (38 loc) · 1.37 KB
/
ModelExpiresServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace Maize\ModelExpires;
use Illuminate\Support\Facades\Event;
use Maize\ModelExpires\Commands\ModelExpiresCheckCommand;
use Maize\ModelExpires\Commands\ModelExpiresDeleteCommand;
use Maize\ModelExpires\Events\ModelExpiring;
use Maize\ModelExpires\Listeners\SendModelExpiringNotification;
use Spatie\LaravelPackageTools\Commands\InstallCommand;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
class ModelExpiresServiceProvider extends PackageServiceProvider
{
public function configurePackage(Package $package): void
{
$package
->name('laravel-model-expires')
->hasConfigFile()
->hasMigration('create_expirations_table')
->hasCommands([
ModelExpiresCheckCommand::class,
ModelExpiresDeleteCommand::class,
])
->hasInstallCommand(
fn (InstallCommand $command) => $command
->publishConfigFile()
->publishMigrations()
->askToRunMigrations()
->askToStarRepoOnGitHub('maize-tech/laravel-model-expires')
);
}
public function packageBooted(): void
{
Event::listen(
events: ModelExpiring::class,
listener: [SendModelExpiringNotification::class, 'handle']
);
}
}