1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DavideCasiraghi\LaravelSmartBlog; |
4
|
|
|
|
5
|
|
|
use Carbon\Carbon; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
|
8
|
|
|
class LaravelSmartBlogServiceProvider extends ServiceProvider |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Bootstrap the application services. |
12
|
|
|
*/ |
13
|
44 |
|
public function boot() |
14
|
|
|
{ |
15
|
|
|
/* |
16
|
|
|
* Optional methods to load your package assets |
17
|
|
|
*/ |
18
|
44 |
|
$this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'laravel-smart-blog'); |
19
|
44 |
|
$this->loadViewsFrom(__DIR__.'/../resources/views', 'laravel-smart-blog'); |
20
|
44 |
|
$this->loadRoutesFrom(__DIR__.'/../routes/web.php'); |
21
|
|
|
|
22
|
44 |
|
$this->app['router']->aliasMiddleware('admin', \DavideCasiraghi\LaravelSmartBlog\Http\Middleware\Admin::class); |
23
|
|
|
|
24
|
44 |
|
if ($this->app->runningInConsole()) { |
25
|
44 |
|
$this->publishes([ |
26
|
44 |
|
__DIR__.'/../config/config.php' => config_path('laravel-smart-blog.php'), |
27
|
44 |
|
], 'config'); |
28
|
|
|
|
29
|
|
|
// Publishing the views. |
30
|
|
|
/*$this->publishes([ |
31
|
|
|
__DIR__.'/../resources/views' => resource_path('views/vendor/laravel-smart-blog'), |
32
|
|
|
], 'views');*/ |
33
|
|
|
|
34
|
|
|
// Publishing assets. |
35
|
|
|
/*$this->publishes([ |
36
|
|
|
__DIR__.'/../resources/assets' => public_path('vendor/laravel-smart-blog'), |
37
|
|
|
], 'assets');*/ |
38
|
44 |
|
$this->publishes([ |
39
|
44 |
|
__DIR__.'/../resources/assets/sass' => resource_path('sass/vendor/laravel-smart-blog/'), |
40
|
44 |
|
], 'sass'); |
41
|
44 |
|
$this->publishes([ |
42
|
44 |
|
__DIR__.'/../resources/assets/js' => resource_path('js/vendor/laravel-smart-blog/'), |
43
|
44 |
|
], 'js'); |
44
|
|
|
|
45
|
|
|
// Publishing the translation files. |
46
|
44 |
|
$this->publishes([ |
47
|
44 |
|
__DIR__.'/../resources/lang' => resource_path('lang/vendor/laravel-smart-blog'), |
48
|
44 |
|
], 'lang'); |
49
|
|
|
|
50
|
|
|
// Registering package commands. |
51
|
|
|
// $this->commands([]); |
52
|
|
|
|
53
|
|
|
/* - Migrations - |
54
|
|
|
create a migration instance for each .php.stub file eg. |
55
|
|
|
create_continents_table.php.stub ---> 2019_04_28_190434761474_create_continents_table.php |
56
|
|
|
*/ |
57
|
|
|
$migrations = [ |
58
|
44 |
|
'CreateBlogsTable' => 'create_blogs_table', |
59
|
|
|
'CreateCategoriesTable' => 'create_categories_table', |
60
|
|
|
'CreateCategoryTranslationsTable' => 'create_category_translations_table', |
61
|
|
|
'CreatePostsTable' => 'create_posts_table', |
62
|
|
|
'CreatePostTranslationsTable' => 'create_post_translations_table', |
63
|
|
|
]; |
64
|
|
|
|
65
|
44 |
|
foreach ($migrations as $migrationFunctionName => $migrationFileName) { |
66
|
44 |
|
if (! class_exists($migrationFunctionName)) { |
67
|
1 |
|
$this->publishes([ |
68
|
1 |
|
__DIR__.'/../database/migrations/'.$migrationFileName.'.php.stub' => database_path('migrations/'.Carbon::now()->format('Y_m_d_Hmsu').'_'.$migrationFileName.'.php'), |
69
|
44 |
|
], 'migrations'); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
} |
73
|
44 |
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Register the application services. |
77
|
|
|
*/ |
78
|
44 |
|
public function register() |
79
|
|
|
{ |
80
|
|
|
// Automatically apply the package configuration |
81
|
44 |
|
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'laravel-smart-blog'); |
82
|
|
|
|
83
|
|
|
// Register the main class to use with the facade |
84
|
|
|
$this->app->singleton('laravel-smart-blog', function () { |
85
|
|
|
return new LaravelSmartBlog; |
86
|
44 |
|
}); |
87
|
44 |
|
} |
88
|
|
|
} |
89
|
|
|
|