|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace FaithGen\News\Providers; |
|
4
|
|
|
|
|
5
|
|
|
use FaithGen\News\Models\News; |
|
6
|
|
|
use FaithGen\News\Observers\NewsObserver; |
|
7
|
|
|
use FaithGen\News\Services\NewsService; |
|
8
|
|
|
use FaithGen\SDK\Traits\ConfigTrait; |
|
9
|
|
|
use Illuminate\Support\ServiceProvider; |
|
10
|
|
|
|
|
11
|
|
|
class NewsServiceProvider extends ServiceProvider |
|
12
|
|
|
{ |
|
13
|
|
|
use ConfigTrait; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Bootstrap services. |
|
17
|
|
|
* |
|
18
|
|
|
* @return void |
|
19
|
|
|
*/ |
|
20
|
|
|
public function boot() |
|
21
|
|
|
{ |
|
22
|
|
|
$this->registerRoutes(__DIR__.'/../../routes/news.php', __DIR__.'/../../routes/source.php'); |
|
23
|
|
|
|
|
24
|
|
|
$this->setUpSourceFiles(function () { |
|
25
|
|
|
$this->loadMigrationsFrom(__DIR__.'/../../database/migrations'); |
|
26
|
|
|
|
|
27
|
|
|
$this->publishes([ |
|
28
|
|
|
__DIR__.'/../../storage/news/' => storage_path('app/public/news'), |
|
29
|
|
|
], 'faithgen-news-storage'); |
|
30
|
|
|
|
|
31
|
|
|
$this->publishes([ |
|
32
|
|
|
__DIR__.'/../../database/migrations/' => database_path('migrations'), |
|
33
|
|
|
], 'faithgen-news-migrations'); |
|
34
|
|
|
}); |
|
35
|
|
|
|
|
36
|
|
|
$this->publishes([ |
|
37
|
|
|
__DIR__.'/../../config/faithgen-news.php' => config_path('faithgen-news.php'), |
|
38
|
|
|
], 'faithgen-news-config'); |
|
39
|
|
|
|
|
40
|
|
|
News::observe(NewsObserver::class); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function register() |
|
44
|
|
|
{ |
|
45
|
|
|
$this->mergeConfigFrom(__DIR__.'/../../config/faithgen-news.php', 'faithgen-news'); |
|
46
|
|
|
|
|
47
|
|
|
$this->app->singleton(NewsService::class); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* The config you want to be applied onto your routes. |
|
52
|
|
|
* @return array the rules eg, middleware, prefix, namespace |
|
53
|
|
|
*/ |
|
54
|
|
|
public function routeConfiguration(): array |
|
55
|
|
|
{ |
|
56
|
|
|
return [ |
|
57
|
|
|
'prefix' => config('faithgen-news.prefix'), |
|
58
|
|
|
'middleware' => config('faithgen-news.middlewares'), |
|
59
|
|
|
]; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|