1
|
|
|
<?php namespace Arcanesoft\Blog; |
2
|
|
|
|
3
|
|
|
use Arcanesoft\Core\Bases\PackageServiceProvider; |
4
|
|
|
use Illuminate\Support\Arr; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Class BlogServiceProvider |
8
|
|
|
* |
9
|
|
|
* @package Arcanesoft\Blog |
10
|
|
|
* @author ARCANEDEV <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
class BlogServiceProvider extends PackageServiceProvider |
13
|
|
|
{ |
14
|
|
|
/* ----------------------------------------------------------------- |
15
|
|
|
| Properties |
16
|
|
|
| ----------------------------------------------------------------- |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Package name. |
21
|
|
|
* |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
protected $package = 'blog'; |
25
|
|
|
|
26
|
|
|
/* ----------------------------------------------------------------- |
27
|
|
|
| Main Methods |
28
|
|
|
| ----------------------------------------------------------------- |
29
|
|
|
*/ |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Register the service provider. |
33
|
|
|
*/ |
34
|
9 |
|
public function register() |
35
|
|
|
{ |
36
|
9 |
|
parent::register(); |
37
|
|
|
|
38
|
9 |
|
$this->registerConfig(); |
39
|
9 |
|
$this->registerSidebarItems(); |
40
|
|
|
|
41
|
9 |
|
$this->registerProviders([ |
42
|
9 |
|
Providers\AuthorizationServiceProvider::class, |
43
|
3 |
|
Providers\ViewComposerServiceProvider::class, |
44
|
3 |
|
Providers\RouteServiceProvider::class, |
45
|
3 |
|
\Arcanedev\LaravelMarkdown\LaravelMarkdownServiceProvider::class, |
46
|
3 |
|
]); |
47
|
9 |
|
$this->registerConsoleServiceProvider(Providers\CommandServiceProvider::class); |
48
|
9 |
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Boot the service provider. |
52
|
|
|
*/ |
53
|
9 |
|
public function boot() |
54
|
|
|
{ |
55
|
9 |
|
parent::boot(); |
56
|
|
|
|
57
|
9 |
|
$this->registerObservers(); |
58
|
|
|
|
59
|
|
|
// Publishes |
60
|
|
|
$this->publishConfig(); |
61
|
|
|
$this->publishViews(); |
62
|
|
|
$this->publishTranslations(); |
63
|
|
|
$this->publishSidebarItems(); |
64
|
|
|
|
65
|
|
|
Blog::$runsMigrations ? $this->loadMigrations() : $this->publishMigrations(); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Get the services provided by the provider. |
70
|
|
|
* |
71
|
|
|
* @return array |
72
|
|
|
*/ |
73
|
|
|
public function provides() |
74
|
|
|
{ |
75
|
|
|
return [ |
76
|
|
|
// |
77
|
|
|
]; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/* ----------------------------------------------------------------- |
81
|
|
|
| Other Methods |
82
|
|
|
| ----------------------------------------------------------------- |
83
|
|
|
*/ |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Register the observers. |
87
|
|
|
*/ |
88
|
9 |
|
private function registerObservers() |
89
|
|
|
{ |
90
|
9 |
|
$config = $this->config()->get('arcanesoft.blog'); |
91
|
|
|
|
92
|
9 |
|
foreach (Arr::only($config, ['posts', 'categories', 'tags']) as $entity) { |
93
|
9 |
|
$this->app->make($entity['model'])->observe($entity['observer']); |
94
|
3 |
|
} |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|