Skip to content

Commit

Permalink
Now you can filter user by their role
Browse files Browse the repository at this point in the history
  • Loading branch information
rahmanramsi committed Nov 25, 2023
1 parent 02686eb commit 0836e28
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions app/Panel/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Filament\Tables\Columns\Layout\Stack;
use Filament\Tables\Columns\SpatieMediaLibraryImageColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Arr;
Expand Down Expand Up @@ -167,8 +168,7 @@ public static function table(Table $table): Table
->extraCellAttributes([
'style' => 'width: 1px',
])
->circular()
->toggleable(),
->circular(),
Stack::make([
TextColumn::make('full_name')
->weight(FontWeight::Medium)
Expand All @@ -181,8 +181,7 @@ public static function table(Table $table): Table
query: fn ($query, $direction) => $query
->orderBy('given_name', $direction)
->orderBy('family_name', $direction)
)
->toggleable(),
),
TextColumn::make('email')
->wrap()
->color('gray')
Expand Down Expand Up @@ -214,6 +213,10 @@ public static function table(Table $table): Table
->color('danger')
->badge(),
]),
Stack::make([
TextColumn::make('roles.name')
->badge()
])
// Stack::make([
// TextColumn::make('phone')
// ->icon('heroicon-m-phone')
Expand All @@ -231,11 +234,13 @@ public static function table(Table $table): Table
// ->icon('academicon-scopus-square')
// ->getStateUsing(fn (User $record) => $record->getMeta('scopus_id')),
// ])
])
->from('md'),
])->from('md'),
])
->filters([
// ...
SelectFilter::make('roles')
->relationship('roles', 'name')
->multiple()
->preload()
])
->actions([
EditAction::make()
Expand Down

0 comments on commit 0836e28

Please sign in to comment.