Closed SV-RAJA closed 5 years ago
What version of the package are you using? Also what version of Laravel are you running? Finally, what fields are you using?
crestapp 2.2 in laravel 5.7
What about the fields so I can attempt to reproduce the error
php artisan resource-file:create AssetCategory --fields=id,name,description,is_active
What's my error?
Hi I am having the same issue! Using CreatApps 2.2/Laravel 5.7. I have logged logged issue #102... sorry for the duplication!
Is there a solution to this problem? Thanks
I run the command in php7.3 and fails , downgrade to php7.2 works fine. I do not know why. :|
Before PHP 7.3, any strings that are not set will silently be skipped. function compact
Run the following function to force php 7.2 version:
php7.2 artisan create:resources ...
@limonazzo because PHP 7.3 now reports missing variables in the compact function.
If you view the code (vendor/crestapps/laravel-code-generator/src/Commands/CreateControllerCommand.php, method getCommandInput) $viewName, $fileSnippet and $fields are not defined. For now i comment out these variables to prevent errors in PHP7.3
protected function getCommandInput()
{
$modelName = trim($this->argument('model-name'));
$cName = trim($this->option('controller-name'));
$controllerName = $cName ? str_finish($cName, Config::getControllerNamePostFix()) : Helpers::makeControllerName($modelName);
$viewDirectory = $this->option('views-directory');
$prefix = ($this->option('routes-prefix') == 'default-form') ? Helpers::makeRouteGroup($modelName) : $this->option('routes-prefix');
$perPage = intval($this->option('models-per-page'));
$resourceFile = trim($this->option('resource-file')) ?: Helpers::makeJsonFileName($modelName);
$langFile = $this->option('language-filename') ?: Helpers::makeLocaleGroup($modelName);
$withFormRequest = $this->option('with-form-request');
$force = $this->option('force');
$modelDirectory = $this->option('model-directory');
$controllerDirectory = trim($this->option('controller-directory'));
$formRequestName = Helpers::makeFormRequestName($modelName);
$template = $this->getTemplateName();
$formRequestDirectory = trim($this->option('form-request-directory'));
$extends = $this->generatorOption('controller-extends');
$withAuth = $this->option('with-auth');
return (object) compact(
'formRequestDirectory',
'viewDirectory',
//'viewName',
'modelName',
'prefix',
'perPage',
//'fileSnippet',
'modelDirectory',
'langFile',
//'fields',
'withFormRequest',
'formRequestName',
'force',
'resourceFile',
'template',
'controllerName',
'extends',
'withAuth',
'controllerDirectory'
);
}
Thank you for reporting this issue! This issue has been addressed and now part of the v2.2.13 release. Please upgrade your package to fix the issue
F:\nidhi - Login Email HtmlCollective CodeGenerator>php artisan create:resources AssetCategory --with-migration Scaffolding resources for asset category... A model was crafted successfully.
ErrorException : compact(): Undefined variable: viewName
at F:\nidhi - Login Email HtmlCollective CodeGenerator\vendor\crestapps\laravel-code-generator\src\Commands\CreateControllerCommand.php:398 394| 'template', 395| 'controllerName', 396| 'extends', 397| 'withAuth',
Exception trace:
1 compact("formRequestDirectory", "viewDirectory", "viewName", "modelName", "prefix", "perPage", "fileSnippet", "modelDirectory", "langFile", "fields", "withFormRequest", "formRequestName", "force", "resourceFile", "template", "controllerName", "extends", "withAuth", "controllerDirectory") F:\nidhi - Login Email HtmlCollective CodeGenerator\vendor\crestapps\laravel-code-generator\src\Commands\CreateControllerCommand.php:398