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