Completed
Push — master ( 3cd9a5...983ab2 )
by ARCANEDEV
03:07
created

BlogServiceProvider::provides()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 2
cts 2
cp 1
rs 9.4285
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php namespace Arcanesoft\Blog;
2
3
use Arcanesoft\Core\Bases\PackageServiceProvider;
4
5
/**
6
 * Class     BlogServiceProvider
7
 *
8
 * @package  Arcanesoft\Blog
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class BlogServiceProvider extends PackageServiceProvider
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Properties
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * Package name.
19
     *
20
     * @var string
21
     */
22
    protected $package = 'blog';
23
24
    /* ------------------------------------------------------------------------------------------------
25
     |  Getters & Setters
26
     | ------------------------------------------------------------------------------------------------
27
     */
28
    /**
29
     * Get the base path of the package.
30
     *
31
     * @return string
32
     */
33 8
    public function getBasePath()
34
    {
35 8
        return dirname(__DIR__);
36
    }
37
38
    /**
39
     * Get config key.
40
     *
41
     * @return string
42
     */
43 8
    protected function getConfigKey()
44
    {
45 8
        return str_slug($this->vendor . ' ' .$this->package, '.');
46
    }
47
48
    /* ------------------------------------------------------------------------------------------------
49
     |  Main Functions
50
     | ------------------------------------------------------------------------------------------------
51
     */
52
    /**
53
     * Register the service provider.
54
     */
55 8
    public function register()
56
    {
57 8
        $this->registerConfig();
58 8
        $this->registerSidebarItems();
59 8
    }
60
61
    /**
62
     * Boot the service provider.
63
     */
64 8
    public function boot()
65
    {
66 8
        $this->registerPublishes();
67
68 8
        $this->app->register(Providers\RouteServiceProvider::class);
69 8
    }
70
71
    /**
72
     * Get the services provided by the provider.
73
     *
74
     * @return array
75
     */
76 4
    public function provides()
77
    {
78
        return [
79
            //
80 4
        ];
81
    }
82
83
    /* ------------------------------------------------------------------------------------------------
84
     |  Other Functions
85
     | ------------------------------------------------------------------------------------------------
86
     */
87
    /**
88
     * Register publishes.
89
     */
90 8
    private function registerPublishes()
91
    {
92
        // Config
93 8
        $this->publishes([
94 8
            $this->getConfigFile() => config_path("{$this->vendor}/{$this->package}.php"),
95 8
        ], 'config');
96
97
        // Migrations
98 8
        $this->publishes([
99 8
            $this->getBasePath() . '/database/migrations/' => database_path('migrations'),
100 8
        ], 'migrations');
101
102
        // Views
103 8
        $viewsPath = $this->getBasePath() . '/resources/views';
104
105 8
        $this->loadViewsFrom($viewsPath, $this->package);
106 8
        $this->publishes([
107 8
            $viewsPath => base_path("resources/views/vendor/{$this->package}"),
108 8
        ], 'views');
109
110
        // Translations
111 8
        $translationsPath = $this->getBasePath() . '/resources/lang';
112
113 8
        $this->loadTranslationsFrom($translationsPath, $this->package);
114 8
        $this->publishes([
115 8
            $translationsPath => base_path("resources/lang/vendor/{$this->package}"),
116 8
        ], 'lang');
117 8
    }
118
}
119