1 | <?php |
||
2 | |||
3 | namespace BeyondCode\Mailbox; |
||
4 | |||
5 | use BeyondCode\Mailbox\Facades\Mailbox; |
||
6 | use BeyondCode\Mailbox\Http\Middleware\MailboxBasicAuthentication; |
||
7 | use BeyondCode\Mailbox\Routing\Router; |
||
8 | use Illuminate\Support\Facades\Route; |
||
9 | use Illuminate\Support\ServiceProvider; |
||
10 | |||
11 | class MailboxServiceProvider extends ServiceProvider |
||
12 | { |
||
13 | /** |
||
14 | * Bootstrap the application services. |
||
15 | */ |
||
16 | public function boot() |
||
17 | { |
||
18 | if (! class_exists('CreateMailboxInboundEmailsTable')) { |
||
19 | $this->publishes([ |
||
20 | __DIR__.'/../database/migrations/create_mailbox_inbound_emails_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_mailbox_inbound_emails_table.php'), |
||
21 | ], 'migrations'); |
||
22 | } |
||
23 | |||
24 | $this->publishes([ |
||
25 | __DIR__.'/../config/mailbox.php' => config_path('mailbox.php'), |
||
26 | ], 'config'); |
||
27 | |||
28 | Route::aliasMiddleware('laravel-mailbox', MailboxBasicAuthentication::class); |
||
29 | |||
30 | $this->commands([ |
||
31 | Console\CleanEmails::class, |
||
32 | ]); |
||
33 | |||
34 | $this->registerDriver(); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Register the application services. |
||
39 | */ |
||
40 | public function register() |
||
41 | { |
||
42 | $this->mergeConfigFrom(__DIR__.'/../config/mailbox.php', 'mailbox'); |
||
43 | |||
44 | $this->app->singleton('mailbox', function () { |
||
45 | return new Router($this->app); |
||
46 | }); |
||
47 | |||
48 | $this->app->singleton(MailboxManager::class, function () { |
||
49 | return new MailboxManager($this->app); |
||
50 | }); |
||
51 | } |
||
52 | |||
53 | protected function registerDriver() |
||
54 | { |
||
55 | Mailbox::mailbox()->register(); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
56 | } |
||
57 | } |
||
58 |