Skip to content

Commit

Permalink
Merge pull request #10 from Log1x/enhance/menu-table-columns
Browse files Browse the repository at this point in the history
💄 Add locations to the menu table
  • Loading branch information
datlechin authored Aug 9, 2024
2 parents c3e6721 + 00a5e98 commit 8da8512
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions resources/lang/en/menu-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'locations' => [
'label' => 'Locations',
'description' => 'Choose where to display the menu.',
'empty' => 'Unassigned',
],
'is_visible' => [
'label' => 'Visible',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/vi/menu-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'locations' => [
'label' => 'Vị trí',
'description' => 'Chọn vị trí hiển thị menu.',
'empty' => 'Chưa gán',
],
'is_visible' => [
'label' => 'Hiển thị',
Expand Down
8 changes: 8 additions & 0 deletions src/Resources/MenuResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,19 @@ public static function form(Form $form): Form

public static function table(Table $table): Table
{
$locations = FilamentMenuBuilderPlugin::get()->getLocations();

return $table
->columns([
Tables\Columns\TextColumn::make('name')
->searchable()
->label(__('filament-menu-builder::menu-builder.resource.name.label')),
Tables\Columns\TextColumn::make('locations.location')
->default($default = __('filament-menu-builder::menu-builder.resource.locations.empty'))
->color(fn (string $state) => $state !== $default ? 'primary' : 'gray')
->formatStateUsing(fn (string $state) => $locations[$state] ?? $state)
->limitList(2)
->badge(),
Tables\Columns\IconColumn::make('is_visible')
->label(__('filament-menu-builder::menu-builder.resource.is_visible.label'))
->boolean(),
Expand Down

0 comments on commit 8da8512

Please sign in to comment.