From 5a2e921524d8752c2d2d619ad6be382452b506e3 Mon Sep 17 00:00:00 2001 From: A Web Artisan <57477934+thewebartisan7@users.noreply.github.com> Date: Wed, 26 Aug 2020 11:38:27 +0200 Subject: [PATCH 1/5] Add view namespace --- src/Generators/Scaffold/ViewGenerator.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Generators/Scaffold/ViewGenerator.php b/src/Generators/Scaffold/ViewGenerator.php index d52386fcc..e2fb942b1 100755 --- a/src/Generators/Scaffold/ViewGenerator.php +++ b/src/Generators/Scaffold/ViewGenerator.php @@ -282,7 +282,12 @@ 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; } From 91f87b6b832e58c1625d73b3ff586cedf5c8daf6 Mon Sep 17 00:00:00 2001 From: A Web Artisan <57477934+thewebartisan7@users.noreply.github.com> Date: Wed, 26 Aug 2020 11:39:55 +0200 Subject: [PATCH 2/5] View namespace --- src/Common/GeneratorConfig.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Common/GeneratorConfig.php b/src/Common/GeneratorConfig.php index 0ec957ae4..882796ae4 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')) { From cf9ad6f540050bfed821846273c51f6044f3760f Mon Sep 17 00:00:00 2001 From: A Web Artisan <57477934+thewebartisan7@users.noreply.github.com> Date: Wed, 26 Aug 2020 12:10:10 +0200 Subject: [PATCH 3/5] Fix styles --- src/Common/GeneratorConfig.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Common/GeneratorConfig.php b/src/Common/GeneratorConfig.php index 882796ae4..c8354e2bd 100755 --- a/src/Common/GeneratorConfig.php +++ b/src/Common/GeneratorConfig.php @@ -401,11 +401,11 @@ public function preparePrefixes() { $this->prefixes['route'] = explode('/', config('infyom.laravel_generator.prefixes.route', '')); $this->prefixes['path'] = explode('/', config('infyom.laravel_generator.prefixes.path', '')); - + /** - * Check if exist view namespace when generate views path is inside a package + * Check if exist view namespace when generate views path is inside a package. */ - if(strpos(config('infyom.laravel_generator.prefixes.view', ''), '::') !== false) { + 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]); @@ -413,7 +413,7 @@ public function preparePrefixes() $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')) { From d483a4fe101cae858b5c66eeed46f886552b191a Mon Sep 17 00:00:00 2001 From: A Web Artisan <57477934+thewebartisan7@users.noreply.github.com> Date: Wed, 26 Aug 2020 12:11:49 +0200 Subject: [PATCH 4/5] Update ViewGenerator.php --- src/Generators/Scaffold/ViewGenerator.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Generators/Scaffold/ViewGenerator.php b/src/Generators/Scaffold/ViewGenerator.php index e2fb942b1..efc723809 100755 --- a/src/Generators/Scaffold/ViewGenerator.php +++ b/src/Generators/Scaffold/ViewGenerator.php @@ -284,10 +284,13 @@ private function generateFields() $tableName = $this->commandData->config->tableName; /** - * Add namespace to 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($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; } From e19c7efe1780541c2e74aa0e316094aadd71f4e8 Mon Sep 17 00:00:00 2001 From: A Web Artisan <57477934+thewebartisan7@users.noreply.github.com> Date: Wed, 26 Aug 2020 12:42:06 +0200 Subject: [PATCH 5/5] Small typo fix --- src/Generators/Scaffold/ViewGenerator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Generators/Scaffold/ViewGenerator.php b/src/Generators/Scaffold/ViewGenerator.php index efc723809..62f2376ea 100755 --- a/src/Generators/Scaffold/ViewGenerator.php +++ b/src/Generators/Scaffold/ViewGenerator.php @@ -286,7 +286,7 @@ private function generateFields() /** * Add namespace to view. */ - if (!empty($this->commandData->config->prefixes['view_namespace'])) { + 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'];