1
|
|
|
<?php namespace Arcanesoft\Blog; |
2
|
|
|
|
3
|
|
|
use Arcanesoft\Blog\Http\Routes\Front as Routes; |
4
|
|
|
use Illuminate\Support\Facades\Route; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Class Blog |
8
|
|
|
* |
9
|
|
|
* @package Arcanesoft\Blog |
10
|
|
|
* @author ARCANEDEV <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
class Blog |
13
|
|
|
{ |
14
|
|
|
/* ----------------------------------------------------------------- |
15
|
|
|
| Properties |
16
|
|
|
| ----------------------------------------------------------------- |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Indicates if migrations will be run. |
21
|
|
|
* |
22
|
|
|
* @var bool |
23
|
|
|
*/ |
24
|
|
|
public static $runsMigrations = true; |
25
|
|
|
|
26
|
|
|
protected static $instance = null; |
27
|
|
|
|
28
|
|
|
/* ----------------------------------------------------------------- |
29
|
|
|
| Main Methods |
30
|
|
|
| ----------------------------------------------------------------- |
31
|
|
|
*/ |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Get the blog instance. |
35
|
|
|
* |
36
|
|
|
* @return Blog |
37
|
|
|
*/ |
38
|
6 |
|
public static function instance() |
39
|
|
|
{ |
40
|
6 |
|
if (is_null(static::$instance)) { |
41
|
3 |
|
static::$instance = new static; |
42
|
|
|
} |
43
|
|
|
|
44
|
6 |
|
return static::$instance; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Publish the migrations. |
49
|
|
|
*/ |
50
|
|
|
public static function publishMigrations() |
51
|
|
|
{ |
52
|
|
|
static::$runsMigrations = false; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Register the public blog routes. |
57
|
|
|
*/ |
58
|
|
|
public static function routes() |
59
|
|
|
{ |
60
|
|
|
Route::name('public::blog.') |
61
|
|
|
->prefix('blog') |
62
|
|
|
->namespace('\\Arcanesoft\\Blog\\Http\\Controllers\\Front') |
63
|
|
|
->group(function () { |
64
|
|
|
Routes\PostsRoutes::register(); |
65
|
|
|
Routes\CategoriesRoutes::register(); |
66
|
|
|
Routes\TagsRoutes::register(); |
67
|
|
|
}); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Check if the blog is translatable. |
72
|
|
|
* |
73
|
|
|
* @return bool |
74
|
|
|
*/ |
75
|
48 |
|
public static function isTranslatable() |
76
|
|
|
{ |
77
|
48 |
|
return config('arcanesoft.blog.translatable.enabled', false); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Check if the blog is seoable. |
82
|
|
|
* |
83
|
|
|
* @return bool |
84
|
|
|
*/ |
85
|
3 |
|
public static function isSeoable() |
86
|
|
|
{ |
87
|
3 |
|
return config('arcanesoft.blog.seoable.enabled', false) |
88
|
3 |
|
&& static::isSeoManagerInstalled(); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Get the supported locales. |
93
|
|
|
* |
94
|
|
|
* @return array |
95
|
|
|
*/ |
96
|
|
|
public static function getSupportedLocalesKeys() |
97
|
|
|
{ |
98
|
|
|
$default = [config('app.locale')]; |
99
|
|
|
|
100
|
|
|
return static::isTranslatable() |
101
|
|
|
? array_unique(config('localization.supported-locales', $default)) |
102
|
|
|
: $default; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Check if the Media manager is installed. |
107
|
|
|
* |
108
|
|
|
* @return bool |
109
|
|
|
*/ |
110
|
3 |
|
public static function isMediaManagerInstalled() |
111
|
|
|
{ |
112
|
3 |
|
return static::hasRegisteredProvider('Arcanesoft\\Media\\MediaServiceProvider'); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Check if the SEO manager is installed. |
117
|
|
|
* |
118
|
|
|
* @return bool |
119
|
|
|
*/ |
120
|
3 |
|
public static function isSeoManagerInstalled() |
121
|
|
|
{ |
122
|
3 |
|
return static::hasRegisteredProvider('Arcanesoft\\Seo\\SeoServiceProvider'); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/* ----------------------------------------------------------------- |
126
|
|
|
| Other Methods |
127
|
|
|
| ----------------------------------------------------------------- |
128
|
|
|
*/ |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Check if the provider was registered in the container. |
132
|
|
|
* |
133
|
|
|
* @param string $provider |
134
|
|
|
* |
135
|
|
|
* @return bool |
136
|
|
|
*/ |
137
|
6 |
|
protected static function hasRegisteredProvider($provider) |
138
|
|
|
{ |
139
|
6 |
|
return array_key_exists($provider, app()->getLoadedProviders()); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
protected function __clone() |
143
|
|
|
{ |
144
|
|
|
// YOU ... SHALL NOT ... CLOOOOOONE! |
145
|
|
|
} |
146
|
|
|
} |
147
|
|
|
|