diff --git a/docs/admin/extending/pages.md b/docs/admin/extending/pages.md index d4ca2b7b4c..8ba953278f 100644 --- a/docs/admin/extending/pages.md +++ b/docs/admin/extending/pages.md @@ -29,6 +29,15 @@ class MyCreateExtension extends CreatePageExtension { return $title . ' - Example'; } + + public function getTabs(array $tabs): array + { + return [ + ...$tabs, + 'review' => Tab::make('Review') + ->modifyQueryUsing(fn (Builder $query) => $query->where('status', 'review')), + ]; + } public function headerWidgets(array $widgets): array { diff --git a/packages/admin/src/Filament/Resources/OrderResource/Pages/ListOrders.php b/packages/admin/src/Filament/Resources/OrderResource/Pages/ListOrders.php index 4d1139bfe4..5da0b626da 100644 --- a/packages/admin/src/Filament/Resources/OrderResource/Pages/ListOrders.php +++ b/packages/admin/src/Filament/Resources/OrderResource/Pages/ListOrders.php @@ -19,7 +19,7 @@ protected function getDefaultHeaderActions(): array ]; } - public function getTabs(): array + public function getDefaultTabs(): array { $statuses = collect( config('lunar.orders.statuses', []) diff --git a/packages/admin/src/Filament/Resources/ProductResource/Pages/ListProducts.php b/packages/admin/src/Filament/Resources/ProductResource/Pages/ListProducts.php index cfc147b0b4..3a979ce033 100644 --- a/packages/admin/src/Filament/Resources/ProductResource/Pages/ListProducts.php +++ b/packages/admin/src/Filament/Resources/ProductResource/Pages/ListProducts.php @@ -78,7 +78,7 @@ public static function createRecord(array $data, string $model): Model return $product; } - public function getTabs(): array + public function getDefaultTabs(): array { return [ 'all' => Tab::make('All'), diff --git a/packages/admin/src/Filament/Resources/ProductVariantResource/Pages/ListProductVariants.php b/packages/admin/src/Filament/Resources/ProductVariantResource/Pages/ListProductVariants.php index 85b7384c77..333ca30898 100644 --- a/packages/admin/src/Filament/Resources/ProductVariantResource/Pages/ListProductVariants.php +++ b/packages/admin/src/Filament/Resources/ProductVariantResource/Pages/ListProductVariants.php @@ -19,7 +19,7 @@ public static function createActionFormInputs(): array return []; } - public function getTabs(): array + public function getDefaultTabs(): array { return []; } diff --git a/packages/admin/src/Support/Extending/ListPageExtension.php b/packages/admin/src/Support/Extending/ListPageExtension.php index 9c3481036e..d882973a1e 100644 --- a/packages/admin/src/Support/Extending/ListPageExtension.php +++ b/packages/admin/src/Support/Extending/ListPageExtension.php @@ -14,6 +14,11 @@ public function subheading($title): ?string return $title; } + public function getTabs(array $tabs): array + { + return $tabs; + } + public function relationManagers(array $managers): array { return $managers; diff --git a/packages/admin/src/Support/Pages/BaseListRecords.php b/packages/admin/src/Support/Pages/BaseListRecords.php index 8601382f3b..dadf83c846 100644 --- a/packages/admin/src/Support/Pages/BaseListRecords.php +++ b/packages/admin/src/Support/Pages/BaseListRecords.php @@ -13,6 +13,7 @@ abstract class BaseListRecords extends ListRecords use Concerns\ExtendsHeaderWidgets; use Concerns\ExtendsHeadings; use Concerns\ExtendsTablePagination; + use Concerns\ExtendsTabs; use \Lunar\Admin\Support\Concerns\CallsHooks; protected function applySearchToTableQuery(Builder $query): Builder diff --git a/packages/admin/src/Support/Pages/Concerns/ExtendsTabs.php b/packages/admin/src/Support/Pages/Concerns/ExtendsTabs.php new file mode 100644 index 0000000000..d7760c2e0c --- /dev/null +++ b/packages/admin/src/Support/Pages/Concerns/ExtendsTabs.php @@ -0,0 +1,16 @@ +callLunarHook('getTabs', $this->getDefaultTabs()); + } +}