fix serach
This commit is contained in:
1 parent
436a8ec142
commit
eb66222c85
1 file changed
+20
-2
+20
-2
@@ -26,11 +26,21 @@ class StatistikoDetailsTable
|
|||||||
->columns([
|
->columns([
|
||||||
Stack::make([
|
Stack::make([
|
||||||
ToggleColumn::make('is_active'),
|
ToggleColumn::make('is_active'),
|
||||||
TextColumn::make('player_name')->color('primary')->icon('phosphor-copy')->copyable()->searchable(),
|
TextColumn::make('player_name')
|
||||||
|
->color('primary')
|
||||||
|
->icon('phosphor-copy')
|
||||||
|
->copyable()
|
||||||
|
->searchable(query: function (Builder $query, string $search): Builder {
|
||||||
|
return $query->where(function (Builder $subQuery) use ($search) {
|
||||||
|
// MongoDB-sichere Suche über 'name' ODER 'email' mittels Regex
|
||||||
|
$subQuery->where('name', 'regexp', '/'.$search.'/i')
|
||||||
|
->orWhere('email', 'regexp', '/'.$search.'/i');
|
||||||
|
});
|
||||||
|
}),
|
||||||
TextColumn::make('ss_player_id')
|
TextColumn::make('ss_player_id')
|
||||||
->color('success')->icon('phosphor-copy')->copyable()
|
->color('success')->icon('phosphor-copy')->copyable()
|
||||||
->searchable(
|
->searchable(
|
||||||
query: fn($query, $search) => $query->orWhere('ss_player_id', (int) $search)
|
query: fn ($query, $search) => $query->orWhere('ss_player_id', (int) $search)
|
||||||
),
|
),
|
||||||
TextColumn::make('positions.name')->badge()->color('warning')
|
TextColumn::make('positions.name')->badge()->color('warning')
|
||||||
->sortable(),
|
->sortable(),
|
||||||
@@ -43,6 +53,13 @@ class StatistikoDetailsTable
|
|||||||
TextColumn::make('last_update')->date()->prefix('Last Update: '),
|
TextColumn::make('last_update')->date()->prefix('Last Update: '),
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
|
->searchQuery(function (Builder $query, string $search): Builder {
|
||||||
|
return $query->where(function (Builder $subQuery) use ($search) {
|
||||||
|
// Nutzen Sie 'regexp' als Operator und packen Sie Flags in den String /.../i
|
||||||
|
$subQuery->where('name', 'regexp', '/'.$search.'/i')
|
||||||
|
->orWhere('email', 'regexp', '/'.$search.'/i');
|
||||||
|
});
|
||||||
|
})
|
||||||
->emptyStateHeading('No double player in details')
|
->emptyStateHeading('No double player in details')
|
||||||
->contentGrid([
|
->contentGrid([
|
||||||
'md' => 2,
|
'md' => 2,
|
||||||
@@ -68,6 +85,7 @@ class StatistikoDetailsTable
|
|||||||
if (! $data['find_double']) {
|
if (! $data['find_double']) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'Find Double';
|
return 'Find Double';
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user