From 3202ec7706cfc6db76dd0da08285f11bc6d8ad83 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Thu, 8 Sep 2022 17:38:06 +0800 Subject: [PATCH 1/3] wip --- src/Traits/HasTabs.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Traits/HasTabs.php b/src/Traits/HasTabs.php index 317fb52..c9163a6 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,7 +42,11 @@ 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) { From b1a48bf5e4f25f0d356cef042aa04b0a20fa1db0 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Thu, 8 Sep 2022 17:39:18 +0800 Subject: [PATCH 2/3] wip --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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": { From 6c9fc606dea21ca11a653104ffd8d5bb4f474389 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Thu, 8 Sep 2022 18:02:38 +0800 Subject: [PATCH 3/3] Update HasTabs.php --- src/Traits/HasTabs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Traits/HasTabs.php b/src/Traits/HasTabs.php index c9163a6..3d7dab9 100644 --- a/src/Traits/HasTabs.php +++ b/src/Traits/HasTabs.php @@ -53,7 +53,7 @@ protected function resolvePanelsFromFields(NovaRequest $request, FieldCollection 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') { @@ -76,7 +76,7 @@ protected function resolvePanelsFromFields(NovaRequest $request, FieldCollection }); return $this->panelsWithDefaultLabel( - $panels->merge($relationPanels), + $panels, $defaultFields->values(), $label );