Viewing file: Main.php (2.73 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
namespace Modules\Cockpit\Providers;
use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider as Provider; use Illuminate\Database\Eloquent\Factory;
class Main extends Provider { /** * Boot the application events. * * @return void */ public function boot() { $this->loadConfig(); $this->loadViews(); $this->loadViewComponents(); $this->loadTranslations(); $this->loadMigrations(); }
/** * Register the service provider. * * @return void */ public function register() { $this->loadRoutes(); }
/** * Load config. * * @return void */ protected function loadConfig() { $this->publishes([ __DIR__ . '/../Config/config.php' => config_path('cockpit.php'), ], 'config');
$this->mergeConfigFrom( __DIR__ . '/../Config/config.php', 'cockpit' ); }
/** * Load views. * * @return void */ public function loadViews() { $viewPath = resource_path('views/modules/cockpit');
$sourcePath = __DIR__ . '/../Resources/views';
$this->publishes([ $sourcePath => $viewPath ],'views');
$this->loadViewsFrom(array_merge(array_map(function ($path) { return $path . '/modules/cockpit'; }, \Config::get('view.paths')), [$sourcePath]), 'cockpit'); }
/** * Load view components. * * @return void */ public function loadViewComponents() { Blade::componentNamespace('Modules\Cockpit\View\Components', 'cockpit'); }
/** * Load translations. * * @return void */ public function loadTranslations() { $langPath = resource_path('lang/modules/cockpit');
if (is_dir($langPath)) { $this->loadTranslationsFrom($langPath, 'cockpit'); } else { $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang/en', 'cockpit'); } }
/** * Load migrations. * * @return void */ public function loadMigrations() { $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); }
/** * Load routes. * * @return void */ public function loadRoutes() { if (app()->routesAreCached()) { return; }
$routes = [ 'web.php', 'api.php', ];
foreach ($routes as $route) { $this->loadRoutesFrom(__DIR__ . '/../Routes/' . $route); } }
/** * Get the services provided by the provider. * * @return array */ public function provides() { return []; } }
|