CrestApps / laravel-code-generator

An efficient Laravel code generator, saving time by automating the creation of resources such as views, controllers, routes, migrations, languages, and form-requests. Highly flexible and customizable, it includes a cross-browser compatible template and client-side validation for application modernization.
https://laravel-code-generator.crestapps.com
MIT License
738 stars 158 forks source link

Demo Errors!!! #107

Closed sanhar closed 5 years ago

sanhar commented 5 years ago

Environment:

Description:

I followed the demo in documentation.

https://crestapps.com/laravel-code-generator/docs/2.2#demo

Steps/Commands To Reproduce:

'php artisan resource-file:create Biography --fields=name,age,biography,sport,gender,colors,is_retired,photo,range,month'

It went ok

'php artisan create:resources Biography --with-form-request --models-per-page=15 --with-migration ' It goes errors following

Content Of The Resource-File:

AIPro$ php artisan create:resources Biography --with-form-request --models-per-page=15 --with-migration Scaffolding resources for biography...

Symfony\Component\Debug\Exception\FatalThrowableError : Argument 1 passed to CrestApps\CodeGenerator\Commands\CreateModelCommand::getPrimaryKeyName() must be an instance of CrestApps\CodeGenerator\Models\Field, null given, called in /Users/binggle/projects/cms-project/demos/crestApp/vendor/crestapps/laravel-code-generator/src/Commands/CreateModelCommand.php on line 512

at /Users/binggle/projects/cms-project/demos/crestApp/vendor/crestapps/laravel-code-generator/src/Commands/CreateModelCommand.php:166 162| @param string $primaryKey 163| 164| @return string 165| /

166| protected function getPrimaryKeyName(Field $primaryField, $primaryKey) 167| { 168| return !is_null($primaryField) ? $primaryField->name : $primaryKey; 169| } 170|

Exception trace:

1 CrestApps\CodeGenerator\Commands\CreateModelCommand::getPrimaryKeyName("id") /Users/binggle/projects/cms-project/demos/crestApp/vendor/crestapps/laravel-code-generator/src/Commands/CreateModelCommand.php:512

2 CrestApps\CodeGenerator\Commands\CreateModelCommand::getNewPrimaryKey("id") /Users/binggle/projects/cms-project/demos/crestApp/vendor/crestapps/laravel-code-generator/src/Commands/CreateModelCommand.php:91

Please use the argument -v to see more details.

I have no idea where to start to fix this.

MikeAlhayek commented 5 years ago

Your fields files does not have a primary key column

Try adding one first using the following command

php artisan resource-file:append Biography --fields=id