Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - Support extend tabs #1725

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/admin/extending/pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected function getDefaultHeaderActions(): array
];
}

public function getTabs(): array
public function getDefaultTabs(): array
{
$statuses = collect(
config('lunar.orders.statuses', [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static function createActionFormInputs(): array
return [];
}

public function getTabs(): array
public function getDefaultTabs(): array
{
return [];
}
Expand Down
5 changes: 5 additions & 0 deletions packages/admin/src/Support/Extending/ListPageExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions packages/admin/src/Support/Pages/BaseListRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions packages/admin/src/Support/Pages/Concerns/ExtendsTabs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Lunar\Admin\Support\Pages\Concerns;

trait ExtendsTabs
{
protected function getDefaultTabs(): array
{
return [];
}

public function getTabs(): array
{
return $this->callLunarHook('getTabs', $this->getDefaultTabs());
}
}
Loading