Skip to content

Commit

Permalink
Updated default module load
Browse files Browse the repository at this point in the history
  • Loading branch information
eusonlito authored Mar 28, 2017
1 parent 9592f76 commit 64d5d38
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/CrudModuleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand Down Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 64d5d38

Please sign in to comment.