1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WebDevEtc\BlogEtc; |
4
|
|
|
|
5
|
|
|
use Gate; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
use WebDevEtc\BlogEtc\Gates\GateTypes; |
8
|
|
|
|
9
|
|
|
class BlogEtcServiceProvider extends ServiceProvider |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Bootstrap services. |
13
|
|
|
* |
14
|
|
|
* @return void |
15
|
|
|
*/ |
16
|
|
|
public function boot() |
17
|
|
|
{ |
18
|
|
|
if (config('blogetc.include_default_routes', true)) { |
19
|
|
|
include __DIR__.'/routes.php'; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
foreach ([ |
23
|
|
|
'2018_05_28_224023_create_blog_etc_posts_table.php', |
24
|
|
|
'2018_09_16_224023_add_author_and_url_blog_etc_posts_table.php', |
25
|
|
|
'2018_09_26_085711_add_short_desc_textrea_to_blog_etc.php', |
26
|
|
|
'2018_09_27_122627_create_blog_etc_uploaded_photos_table.php', |
27
|
|
|
] as $file) { |
28
|
|
|
$this->publishes([ |
29
|
|
|
__DIR__.'/../migrations/'.$file => database_path('migrations/'.$file), |
30
|
|
|
]); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
// Set up default gates to allow/disallow access to features. |
34
|
|
|
$this->setupDefaultGates(); |
35
|
|
|
|
36
|
|
|
$this->publishes([ |
37
|
|
|
__DIR__.'/Views/blogetc' => base_path('resources/views/vendor/blogetc'), |
38
|
|
|
__DIR__.'/Config/blogetc.php' => config_path('blogetc.php'), |
39
|
|
|
__DIR__.'/css/blogetc_admin_css.css' => public_path('blogetc_admin_css.css'), |
40
|
|
|
]); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Set up default gates. |
45
|
|
|
*/ |
46
|
|
|
protected function setupDefaultGates(): void |
47
|
|
|
{ |
48
|
|
|
if (!Gate::has(GateTypes::MANAGE_BLOG_ADMIN)) { |
49
|
|
|
Gate::define(GateTypes::MANAGE_BLOG_ADMIN, include(__DIR__.'/Gates/DefaultAdminGate.php')); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/* |
53
|
|
|
* For people to add comments to your blog posts. By default it will allow anyone - you can add your |
54
|
|
|
* own logic here if needed. |
55
|
|
|
*/ |
56
|
|
|
if (!Gate::has(GateTypes::ADD_COMMENT)) { |
57
|
|
|
Gate::define(GateTypes::ADD_COMMENT, include(__DIR__.'/Gates/DefaultAddCommentsGate.php')); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Register services. |
63
|
|
|
* |
64
|
|
|
* @return void |
65
|
|
|
*/ |
66
|
|
|
public function register() |
67
|
|
|
{ |
68
|
|
|
$this->loadViewsFrom(__DIR__.'/Views/blogetc_admin', 'blogetc_admin'); |
69
|
|
|
|
70
|
|
|
// if you do the vendor:publish, these will be copied to /resources/views/vendor/blogetc anyway |
71
|
|
|
$this->loadViewsFrom(__DIR__.'/Views/blogetc', 'blogetc'); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|