diff --git a/src/Common/GeneratorConfig.php b/src/Common/GeneratorConfig.php index 0ec957ae4..c8354e2bd 100755 --- a/src/Common/GeneratorConfig.php +++ b/src/Common/GeneratorConfig.php @@ -290,7 +290,11 @@ public function loadDynamicVariables(CommandData &$commandData) } if (!empty($this->prefixes['view'])) { - $commandData->addDynamicVariable('$VIEW_PREFIX$', str_replace('/', '.', $this->prefixes['view']).'.'); + if (!empty($this->prefixes['view_namespace'])) { + $commandData->addDynamicVariable('$VIEW_PREFIX$', str_replace('/', '.', $this->prefixes['view_namespace'].'::'.$this->prefixes['view']).'.'); + } else { + $commandData->addDynamicVariable('$VIEW_PREFIX$', str_replace('/', '.', $this->prefixes['view']).'.'); + } } else { $commandData->addDynamicVariable('$VIEW_PREFIX$', ''); } @@ -397,7 +401,19 @@ public function preparePrefixes() { $this->prefixes['route'] = explode('/', config('infyom.laravel_generator.prefixes.route', '')); $this->prefixes['path'] = explode('/', config('infyom.laravel_generator.prefixes.path', '')); - $this->prefixes['view'] = explode('.', config('infyom.laravel_generator.prefixes.view', '')); + + /** + * Check if exist view namespace when generate views path is inside a package. + */ + if (strpos(config('infyom.laravel_generator.prefixes.view', ''), '::') !== false) { + $viewNamespaced = explode('::', config('infyom.laravel_generator.prefixes.view', '')); + $this->prefixes['view_namespace'] = $viewNamespaced[0]; + $this->prefixes['view'] = explode('.', $viewNamespaced[1]); + } else { + $this->prefixes['view_namespace'] = ''; + $this->prefixes['view'] = explode('.', config('infyom.laravel_generator.prefixes.view', '')); + } + $this->prefixes['public'] = explode('/', config('infyom.laravel_generator.prefixes.public', '')); if ($this->getOption('prefix')) { diff --git a/src/Generators/Scaffold/ViewGenerator.php b/src/Generators/Scaffold/ViewGenerator.php index d52386fcc..62f2376ea 100755 --- a/src/Generators/Scaffold/ViewGenerator.php +++ b/src/Generators/Scaffold/ViewGenerator.php @@ -282,7 +282,15 @@ private function generateFields() } $tableName = $this->commandData->config->tableName; - $viewPath = $this->commandData->config->prefixes['view']; + + /** + * Add namespace to view. + */ + if (empty($this->commandData->config->prefixes['view_namespace'])) { + $viewPath = $this->commandData->config->prefixes['view']; + } else { + $viewPath = $this->commandData->config->prefixes['view_namespace'].'::'.$this->commandData->config->prefixes['view']; + } if (!empty($viewPath)) { $tableName = $viewPath.'.'.$tableName; }