Passed
Push — master ( c2d3c3...2d4925 )
by Innocent
06:21
created

MiscellaneousServiceProvider::routeConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Faithgen\Miscellaneous;
4
5
use Faithgen\Miscellaneous\Models\Subscription;
6
use Faithgen\Miscellaneous\Observers\SubscriptionObserver;
7
use Faithgen\Miscellaneous\Services\ContactService;
8
use Faithgen\Miscellaneous\Services\SubscriptionService;
9
use FaithGen\SDK\Traits\ConfigTrait;
10
use Illuminate\Support\ServiceProvider;
11
12
class MiscellaneousServiceProvider extends ServiceProvider
13
{
14
    use ConfigTrait;
15
16
    /**
17
     * Bootstrap the application services.
18
     */
19
    public function boot()
20
    {
21
        $this->registerRoutes(__DIR__.'/../routes/miscellaneous.php', null);
22
23
        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
24
25
        if ($this->app->runningInConsole()) {
26
            $this->publishes([
27
                __DIR__.'/../config/config.php' => config_path('miscellaneous.php'),
28
            ], 'misc-config');
29
30
            $this->publishes([
31
                __DIR__.'/../database/migrations/' => database_path('migrations'),
32
            ], 'miscellaneous-migrations');
33
        }
34
35
        Subscription::observe(SubscriptionObserver::class);
36
    }
37
38
    /**
39
     * Register the application services.
40
     */
41
    public function register()
42
    {
43
        // Automatically apply the package configuration
44
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'miscellaneous');
45
46
        // Register the main class to use with the facade
47
        $this->app->singleton('miscellaneous', function () {
48
            return new Miscellaneous;
49
        });
50
51
        $this->app->singleton(ContactService::class);
52
        $this->app->singleton(SubscriptionService::class);
53
    }
54
55
    public function routeConfiguration(): array
56
    {
57
        return [
58
            'prefix'     => config('miscellaneous.prefix'),
59
            'middleware' => config('miscellaneous.middlewares'),
60
        ];
61
    }
62
}
63