diff --git a/composer.json b/composer.json index 88e0942..406f8ae 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "license": "MIT", "require": { "php": "^7.4|^8", - "laravel/nova": "^4.0", + "laravel/nova": "^4.12", "ext-json": "*" }, "require-dev": { diff --git a/src/Traits/HasTabs.php b/src/Traits/HasTabs.php index 317fb52..3d7dab9 100644 --- a/src/Traits/HasTabs.php +++ b/src/Traits/HasTabs.php @@ -23,13 +23,11 @@ trait HasTabs */ protected function resolvePanelsFromFields(NovaRequest $request, FieldCollection $fields, $label) { - [$relationPanels, $fields] = $fields->transform(function ($field) { - return $field instanceof BehavesAsPanel && !$field->assignedPanel instanceof Tabs ? $field->asPanel() : $field; + [$defaultFields, $fieldsWithPanels] = $fields->each(function ($field) { + if ($field instanceof BehavesAsPanel && !$field->assignedPanel instanceof Tabs) { + $field->asPanel(); + } })->partition(function ($field) { - return $field instanceof Panel; - }); - - [$defaultFields, $fieldsWithPanels] = $fields->partition(function ($field) { return ! isset($field->panel) || blank($field->panel); }); @@ -44,14 +42,18 @@ protected function resolvePanelsFromFields(NovaRequest $request, FieldCollection })->toBase(); if ($panels->where('component', 'tabs')->isEmpty()) { - return parent::resolvePanelsFromFields($request, $fields, $label); + return $this->panelsWithDefaultLabel( + $panels, + $defaultFields->values(), + $label + ); } [$relationshipUnderTabs, $panels] = $panels->partition(function ($panel) { return $panel->component === 'relationship-panel' && $panel->meta['fields'][0]->assignedPanel instanceof Tabs; }); - $panels->transform(function($panel, $key) use($relationshipUnderTabs) { + $panels->transform(function($panel, $key) use ($relationshipUnderTabs) { if ($panel->component === 'tabs') { @@ -74,7 +76,7 @@ protected function resolvePanelsFromFields(NovaRequest $request, FieldCollection }); return $this->panelsWithDefaultLabel( - $panels->merge($relationPanels), + $panels, $defaultFields->values(), $label );