Open lavapi opened 4 years ago
Can you just replace camel_case($table)
with Str::camel($table)
Thanks for letting me know. Yes. i will definitely do that. I am working with V5 and its really cool. Until you have to wait.
I hope you got the error. You already have a migration for your users table. Try something else and it should create migration methods for you.
I fixed it temporarily but just informed you to fix it permanently :) P.S. perfect work...
Hi, in addition to this error I discovered that you don't handle the UNSIGNED attribute in MySQL 8. The "unsigned" is returned with the column data type so it needs to be split first, otherwise the rules method won't match anything and returns nothing for the methodName which causes errors on line 71. Also, it seems to me that you only consider int and bigint for primary keys. Is there a reason for that?
I made some changes starting on line 127
` $dataTypes = explode(' ',$column->type()); $dataType = $dataTypes[0]; $dataTypeAttr = !empty($dataTypes[1])? $dataTypes[1]:'';
if ($column->isPk()) {
if ($dataType == 'int') {
$arr['methodName'] = 'increments';
} elseif ($dataType == 'bigint') {
$arr['methodName'] = 'bigIncrements';
}
}
if (empty($arr['methodName'])) {
$arr['methodName'] = isset($this->columnMap[$dataType]) ? $this->columnMap[$dataType] : '';
}`
I also added 'json' => 'json', to your $columnMap
Works well for my purposes but I didn't test it on anything else. Thanks for a great project :)
@hardkraft thanks for code suggestion. I will definitely implement on next major version 5.0 which is under development now.
I received this exact issue today in a fresh project, fresh "composer require digitaldream/laracrud --dev" - and line 222 had: $class = 'create' . ucfirst(camel_case($table)) . 'Table'; instead of $class = 'create'.Str::camel($table).'Table'; I swapped the lines out and it's fine now... I wish I could offer some insight but I'm a noob out of their depth. Probably something on this end. Otherwise it all looks very spiffy!
Hi @nicholasbieber
This issue is fixed on dev-master
. You can use this version. The next Major version 5 is expected to be release in October this year.
I am getting an error when trying to generate migration from DB.
vendor\digitaldream\laracrud\src\lara-crud\Crud\MigrationCrud.php:222 218| @throws \Exception 219| / 220| public function generateClassName($table) 221| {
Exception trace:
1 LaraCrud\Crud\MigrationCrud::generateClassName("users") vendor\digitaldream\laracrud\src\lara-crud\Crud\MigrationCrud.php:94
2 LaraCrud\Crud\MigrationCrud::template() vendor\digitaldream\laracrud\src\lara-crud\Crud\MigrationCrud.php:110
Please use the argument -v to see more details.