provides()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace CSlant\LaraGenAdv\Providers;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class LaravelGeneratorAdvancedServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Bootstrap services.
11
     *
12
     * @return void
13
     */
14
    public function boot(): void
15
    {
16
        $viewPath = __DIR__.'/../../resources/views';
17
        $this->loadViewsFrom($viewPath, 'lara-gen-adv');
18
19
        $routePath = __DIR__.'/../../routes/web.php';
20
        if (file_exists($routePath)) {
21
            $this->loadRoutesFrom($routePath);
22
        }
23
24
        $this->loadTranslationsFrom(__DIR__.'/../../lang', 'lara-gen-adv');
25
26
        // Load package helpers file
27
        $helpersPath = __DIR__.'/../../common/helpers.php';
28
        if (file_exists($helpersPath)) {
29
            require_once $helpersPath;
30
        }
31
32
        // Publish assets
33
        $this->registerAssetPublishing();
34
    }
35
36
    /**
37
     * Register services.
38
     *
39
     * @return void
40
     */
41
    public function register(): void
42
    {
43
        $configPath = __DIR__.'/../../config/laravel-generator-advanced.php';
44
        $this->mergeConfigFrom($configPath, 'lara-gen-adv');
45
    }
46
47
    /**
48
     * Get the services provided by the provider.
49
     *
50
     * @return array|null
51
     */
52
    public function provides(): ?array
53
    {
54
        return ['lara-gen-adv'];
55
    }
56
57
    /**
58
     * @return void
59
     */
60
    protected function registerAssetPublishing(): void
61
    {
62
        $configPath = __DIR__.'/../../config/laravel-generator-advanced.php';
63
        $this->publishes([
64
            $configPath => config_path('laravel-generator-advanced.php'),
65
        ], 'config');
66
67
        $this->publishes([
68
            __DIR__.'/../../resources/views' => config('lara-gen-adv.defaults.paths.views'),
69
        ], 'views');
70
71
        $this->publishes([
72
            __DIR__.'/../../lang' => resource_path('lang/vendor/laravel-generator-advanced'),
73
        ], 'lang');
74
    }
75
}
76