laravel-nova-nested-form
laravel-nova-nested-form copied to clipboard
BadMethodCallException: Method Illuminate\Database\Query\Builder::getData does not exist.
Hello, I use your package to manage accounts and companies (so I'm able to create a company from a account and link the company to the account). Since I've upgraded to laravel 5.8, I experience this error :
Method Illuminate\Database\Query\Builder::getData does not exist.
when adding a new company (the nested form) to the account (the ressource).
The current release is not compatible with Nova 2/Laravel 5.8, please use the laravel-5.8 branch.
composer require yassi/nova-nested-form:dev-laravel-5.8
Solution
File: FillsSubAttributes.php
Method: runNestedOperations(NovaRequest $request, string $attribute, Model $model)
Line: 223 (phpstorm)
Bug: $this->touched[] = $value->getData()->id
Triggers Bug
protected function runNestedOperations(NovaRequest $request, string $attribute, Model $model)
{
$data = $request->{$attribute} ?? null;
if (is_object($data) || is_array($data)) {
foreach ($data as $index => $value) {
if (!is_int($index)) {
$value = $request->{$attribute};
$index = null;
}
$this->runNestedOperation($value, $model, $attribute, $index, $request);
if ($value instanceof Response) {
abort($value->getStatusCode());
}
$this->touched[] = $value->getData()->id;
if (is_null($index)) {
break;
}
}
} else {
$this->shouldRemoveAll = true;
}
return $this;
}
Solves Bug
protected function runNestedOperations(NovaRequest $request, string $attribute, Model $model)
{
$data = $request->{$attribute} ?? null;
if (is_object($data) || is_array($data)) {
foreach ($data as $index => $value) {
if (!is_int($index)) {
$value = $request->{$attribute};
$index = null;
}
$this->runNestedOperation($value, $model, $attribute, $index, $request);
if ($value instanceof Response) {
abort($value->getStatusCode());
}
$this->touched[] = $value->id;
if (is_null($index)) {
break;
}
}
} else {
$this->shouldRemoveAll = true;
}
return $this;
}