Completed
Push — master ( 891ad0...174c15 )
by Freek
02:49
created

StripeWebhooksServiceProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Spatie\StripeWebhooks;
4
5
use Illuminate\Support\Facades\Route;
6
use Illuminate\Support\ServiceProvider;
7
8
class StripeWebhooksServiceProvider extends ServiceProvider
9
{
10
    public function boot()
11
    {
12
        if ($this->app->runningInConsole()) {
13
            $this->publishes([
14
                __DIR__.'/../config/stripe-webhooks.php' => config_path('stripe-webhooks.php'),
15
            ], 'config');
16
        }
17
18
        if (! class_exists('CreateStripeWebhookCallsTable')) {
19
            $timestamp = date('Y_m_d_His', time());
20
21
            $this->publishes([
22
                __DIR__.'/../database/migrations/create_stripe_webhooks_table.php.stub' => database_path('migrations/'.$timestamp.'_create_stripe_webhooks_table.php'),
23
            ], 'migrations');
24
        }
25
26
        Route::macro('stripeWebhooks', function ($url) {
27
            return Route::post($url, 'Spatie\StripeWebhooks\StripeWebhooksController');
28
        });
29
    }
30
31
    public function register()
32
    {
33
        $this->mergeConfigFrom(__DIR__.'/../config/stripe-webhooks.php', 'stripe-webhooks');
34
    }
35
}
36