From 64d5d38714f86936edbeba78799b1b201986c3cc Mon Sep 17 00:00:00 2001 From: Lito Date: Wed, 29 Mar 2017 00:41:35 +0200 Subject: [PATCH] Updated default module load --- src/CrudModuleProvider.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/CrudModuleProvider.php b/src/CrudModuleProvider.php index 0b2f2eb..4c27001 100644 --- a/src/CrudModuleProvider.php +++ b/src/CrudModuleProvider.php @@ -19,9 +19,23 @@ class CrudModuleProvider extends ModuleProvider * @var bool */ protected $defer = false; + protected static $anavel; + + private function isAnavel() + { + if (self::$anavel !== null) { + return self::$anavel; + } + + return self::$anavel = (config('anavel.route_prefix') === Request::segment(1)); + } public function boot() { + if (!self::isAnavel()) { + return; + } + $this->loadViewsFrom(__DIR__.'/../views', 'anavel-crud'); $this->loadTranslationsFrom(__DIR__.'/../lang', 'anavel-crud'); @@ -42,6 +56,10 @@ public function boot() */ public function register() { + if (!self::isAnavel()) { + return; + } + $this->mergeConfigFrom(__DIR__.'/../config/anavel-crud.php', 'anavel-crud'); $this->app->register('ANavallaSuiza\Laravel\Database\Manager\ModelManagerServiceProvider'); @@ -128,11 +146,7 @@ public function isActive() { $uri = Request::route()->uri(); - if (strpos($uri, 'crud') !== false) { - return true; - } - - return false; + return self::isAnavel() && (strpos($uri, 'crud') !== false); } /**