Skip to content

Commit 30699b7

Browse files
Adding search for collaborators
1 parent 176e90b commit 30699b7

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/Resources/FilamentLatexResource.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,23 @@ public static function table(Table $table): Table
153153
])
154154
->filters([
155155
SelectFilter::make('author_id')
156+
->label(__('filament-latex::filament-latex.column.author.name'))
156157
->default(fn () => Auth::id())
157158
->options(fn () => $userModel::all()->pluck('name', 'id'))
158-
->multiple()
159-
->preload(),
159+
->native(false),
160160
SelectFilter::make('collaborators_id')
161-
->default(fn () => [Auth::id()])
161+
->label(__('filament-latex::filament-latex.column.collaborators'))
162162
->options(fn () => $userModel::all()->pluck('name', 'id'))
163-
// ->query(fn (Builder $query, $data): Builder => dd($data))
164-
->preload(),
163+
->query(function ($query, $data) {
164+
if (! empty($data)) {
165+
// Apply the filter for JSON column
166+
foreach ($data as $id) {
167+
$query->whereJsonContains('collaborators_id', $id);
168+
}
169+
}
170+
})
171+
->multiple()
172+
->native(false),
165173
])
166174
->actions([
167175
Tables\Actions\ActionGroup::make([

0 commit comments

Comments
 (0)