Skip to content

Commit bffd657

Browse files
committed
sort templates and layouts sorted by name and created at
1 parent c4c7273 commit bffd657

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/Resources/LayoutResource.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public static function table(Table $table): Table
5656
return $table
5757
->columns([
5858
Tables\Columns\TextColumn::make('name')
59-
->searchable(),
59+
->searchable()
60+
->sortable(),
6061

6162
Tables\Columns\TextColumn::make('templates_count'),
6263

@@ -65,12 +66,14 @@ public static function table(Table $table): Table
6566
->formatStateUsing(fn (?User $state) => $state?->getFilamentName() ?: '-'),
6667

6768
Tables\Columns\TextColumn::make('created_at')
68-
->dateTime(),
69+
->dateTime()
70+
->sortable(),
6971
])
7072
->actions([
7173
Tables\Actions\EditAction::make(),
7274
])
73-
->bulkActions([]);
75+
->bulkActions([])
76+
->defaultSort('name');
7477
}
7578

7679
/**

src/Resources/TemplateResource.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public static function table(Table $table): Table
4343
{
4444
return $table
4545
->columns([
46-
Tables\Columns\TextColumn::make('name')->searchable(),
46+
Tables\Columns\TextColumn::make('name')
47+
->searchable()
48+
->sortable(),
4749

4850
Tables\Columns\TextColumn::make('layout')
4951
->label('Layout')
@@ -53,7 +55,9 @@ public static function table(Table $table): Table
5355
->label('User')
5456
->formatStateUsing(fn (?User $state) => $state?->getFilamentName() ?: '-'),
5557

56-
Tables\Columns\TextColumn::make('created_at')->dateTime(),
58+
Tables\Columns\TextColumn::make('created_at')
59+
->dateTime()
60+
->sortable(),
5761
])
5862
->actions([
5963
Tables\Actions\EditAction::make(),
@@ -72,7 +76,8 @@ public static function table(Table $table): Table
7276
]);
7377
}),
7478
])
75-
->bulkActions([]);
79+
->bulkActions([])
80+
->defaultSort('name');
7681
}
7782

7883
/**

0 commit comments

Comments
 (0)