|
@@ -63,26 +63,70 @@ class AdminServiceProvider extends ServiceProvider
|
|
|
* @return void
|
|
|
*/
|
|
|
public function boot()
|
|
|
+ {
|
|
|
+ $this->registerViews();
|
|
|
+ $this->ensureHttps();
|
|
|
+ $this->registerRoutes();
|
|
|
+ $this->registerPublishing();
|
|
|
+ $this->compatibleBlade();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Register the service provider.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function register()
|
|
|
+ {
|
|
|
+ require_once __DIR__ . '/Support/AdminSection.php';
|
|
|
+
|
|
|
+ $this->registerExtensionProviders();
|
|
|
+ $this->loadAdminAuthConfig();
|
|
|
+ $this->registerRouteMiddleware();
|
|
|
+ $this->registerService();
|
|
|
+ $this->registerDefaultSections();
|
|
|
+
|
|
|
+ $this->commands($this->commands);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Register the view file namespace.
|
|
|
+ */
|
|
|
+ protected function registerViews()
|
|
|
{
|
|
|
$this->loadViewsFrom(__DIR__.'/../resources/views', 'admin');
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * Force to set https scheme if https enabled.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ protected function ensureHttps()
|
|
|
+ {
|
|
|
if (config('admin.https') || config('admin.secure')) {
|
|
|
\URL::forceScheme('https');
|
|
|
$this->app['request']->server->set('HTTPS', true);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * Register routes
|
|
|
+ */
|
|
|
+ protected function registerRoutes()
|
|
|
+ {
|
|
|
if (is_file($routes = admin_path('routes.php'))) {
|
|
|
$this->loadRoutesFrom($routes);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if ($this->app->runningInConsole()) {
|
|
|
- $this->publishes([__DIR__.'/../config' => config_path()], 'dcat-admin-config');
|
|
|
- $this->publishes([__DIR__.'/../resources/lang' => resource_path('lang')], 'dcat-admin-lang');
|
|
|
- $this->publishes([__DIR__.'/../database/migrations' => database_path('migrations')], 'dcat-admin-migrations');
|
|
|
- $this->publishes([__DIR__.'/../resources/assets' => public_path('vendor/dcat-admin')], 'dcat-admin-assets');
|
|
|
- }
|
|
|
-
|
|
|
- //remove default feature of double encoding enable in laravel 5.6 or later.
|
|
|
+ /**
|
|
|
+ * Remove default feature of double encoding enable in laravel 5.6 or later.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ protected function compatibleBlade()
|
|
|
+ {
|
|
|
$bladeReflectionClass = new \ReflectionClass('\Illuminate\View\Compilers\BladeCompiler');
|
|
|
if ($bladeReflectionClass->hasMethod('withoutDoubleEncoding')) {
|
|
|
Blade::withoutDoubleEncoding();
|
|
@@ -90,21 +134,18 @@ class AdminServiceProvider extends ServiceProvider
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Register the service provider.
|
|
|
+ * Register the package's publishable resources.
|
|
|
*
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function register()
|
|
|
+ protected function registerPublishing()
|
|
|
{
|
|
|
- require_once __DIR__ . '/Support/AdminSection.php';
|
|
|
-
|
|
|
- $this->registerExtensionProviders();
|
|
|
- $this->loadAdminAuthConfig();
|
|
|
- $this->registerRouteMiddleware();
|
|
|
- $this->registerService();
|
|
|
- $this->registerDefaultSections();
|
|
|
-
|
|
|
- $this->commands($this->commands);
|
|
|
+ if ($this->app->runningInConsole()) {
|
|
|
+ $this->publishes([__DIR__.'/../config' => config_path()], 'dcat-admin-config');
|
|
|
+ $this->publishes([__DIR__.'/../resources/lang' => resource_path('lang')], 'dcat-admin-lang');
|
|
|
+ $this->publishes([__DIR__.'/../database/migrations' => database_path('migrations')], 'dcat-admin-migrations');
|
|
|
+ $this->publishes([__DIR__.'/../resources/assets' => public_path('vendor/dcat-admin')], 'dcat-admin-assets');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|