InfyOmLabs / laravel-generator

API and Admin Panel CRUD Generator for Laravel.
https://www.infyom.com/open-source
MIT License
3.79k stars 812 forks source link

Call to a member function isPrimary() on string #547

Closed lomotech closed 6 years ago

lomotech commented 6 years ago

Running artisan infyom:api_scaffold XrefOption --fromTable from my terminal and then get the error

Symfony\Component\Debug\Exception\FatalThrowableError  : 
Call to a member function isPrimary() on string at 
/private/var/www/html/semut/vendor/infyomlabs/laravel-generator/src/Utils/TableFieldsGenerator.php:125

That is refer to this line:

$primaryKey = $indexes->first(function ($i, $index) {
      return $index->isPrimary() && 1 === count($index->getColumns());
});

I trying to change from $index to $i,

$primaryKey = $indexes->first(function ($i, $index) {
      return $i->isPrimary() && 1 === count($i->getColumns());
});

now its working. But not very sure why and when this begin to happen.

PHP 7.1, L 5.6

"infyomlabs/core-templates": "dev-master",
"infyomlabs/laravel-generator": "dev-master",
"infyomlabs/swagger-generator": "dev-master",
lomotech commented 6 years ago

found the issue, change the library to use 5.6 tag

"infyomlabs/adminlte-templates": "5.6.x-dev",
"infyomlabs/laravel-generator": "5.6.x-dev",