-
-
Notifications
You must be signed in to change notification settings - Fork 160
Open
Description
Environment:
- Laravel-Code-Generator Version: v2.4.4
- Laravel Version: v8.64.0
Description:
Following the documentation, this command php artisan resource-file:create
could not work with --relations
parameters.
Steps:
php artisan resource-file:append Post --fields="name:another" --relations="name:comments;type:hasMany;field:title;params:App\Models\Comment|post_id|id"
Running the cammand above would generate
ErrorException
Undefined offset: 1
The culprit seems to be the line below
at ...\crestapps\laravel-code-generator\src\Models\ForeignRelationship.php:490
486▕ if (!str_contains($part, ':')) {
487▕ continue;
488▕ }
489▕
➜ 490▕ list($key, $value) = Str::split([':', '='], $part);
491▕
492▕ if (($isParams = in_array($key, ['params', 'param'])) || str_contains($value, '|')) {
493▕ $value = explode('|', $value);
494▕
A quick dirty fix was changing the line to:
list($key, $value) = Str::split(':', $part);
Metadata
Metadata
Assignees
Labels
No labels