TestimoniesServiceProvider::routeConfiguration()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Faithgen\Testimonies;
4
5
use FaithGen\SDK\Services\ImageService;
6
use FaithGen\SDK\Traits\ConfigTrait;
7
use Faithgen\Testimonies\Models\Testimony;
8
use Faithgen\Testimonies\Observers\TestimonyObserver;
9
use Faithgen\Testimonies\Services\TestimoniesService;
10
use Illuminate\Support\ServiceProvider;
11
12
final class TestimoniesServiceProvider extends ServiceProvider
13
{
14
    use ConfigTrait;
15
16
    /**
17
     * Bootstrap the application services.
18
     */
19
    public function boot(): void
20
    {
21
        $this->registerRoutes(__DIR__.'/../routes/testimonies.php', __DIR__.'/../routes/source.php');
22
23
        $this->setUpSourceFiles(function () {
24
            $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
25
26
            $this->loadFactoriesFrom(__DIR__.'/../database/factories');
27
28
            $this->publishes([
29
                __DIR__.'/../database/migrations/' => database_path('migrations'),
30
            ], 'faithgen-testimonies-migrations');
31
        });
32
33
        if (! config('faithgen-sdk.source')) {
34
            $this->publishes([
35
                __DIR__.'/../storage/' => storage_path('app/public/testimonies'),
36
            ], 'faithgen-testimonies-storage');
37
        }
38
39
        $this->publishes([
40
            __DIR__.'/../config/config.php' => config_path('faithgen-testimonies.php'),
41
        ], 'faithgen-testimonies-config');
42
43
        Testimony::observe(TestimonyObserver::class);
44
    }
45
46
    /**
47
     * Register the application services.
48
     */
49
    public function register(): void
50
    {
51
        // Automatically apply the package configuration
52
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'faithgen-testimonies');
53
54
        // Register the main class to use with the facade
55
        $this->app->singleton('testimonies', function () {
56
            return new Testimonies();
57
        });
58
59
        //register testimony services
60
        $this->app->singleton(TestimoniesService::class);
61
        $this->app->singleton(ImageService::class);
62
    }
63
64
    public function routeConfiguration(): array
65
    {
66
        return [
67
            'prefix' => config('faithgen-testimonies.prefix'),
68
            'middleware' => config('faithgen-testimonies.middlewares'),
69
        ];
70
    }
71
}
72