Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/Common/GeneratorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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$', '');
}
Expand Down Expand Up @@ -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')) {
Expand Down
10 changes: 9 additions & 1 deletion src/Generators/Scaffold/ViewGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down