File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace App \Filament \Admin \Livewire ;
4+
5+ use Filament \Facades \Filament ;
6+ use Filament \Livewire \GlobalSearch as BaseGlobalSearch ;
7+
8+ class GlobalSearch extends BaseGlobalSearch
9+ {
10+ public function updatedSearch (): void
11+ {
12+ if (Filament::getCurrentPanel ()?->getId() !== 'app ' ) {
13+ return ;
14+ }
15+
16+ $ search = trim ($ this ->search );
17+
18+ // Enforce cid only
19+ if (blank ($ search ) || ! ctype_digit ($ search )) {
20+ return ;
21+ }
22+
23+ $ results = $ this ->getResults ();
24+
25+ if ($ results === null ) {
26+ return ;
27+ }
28+
29+ $ allResults = collect ($ results ->getCategories ())
30+ ->flatten ();
31+
32+ if ($ allResults ->count () === 1 ) {
33+ $ this ->redirect ($ allResults ->first ()->url );
34+ }
35+ }
36+ }
Original file line number Diff line number Diff line change 22
33namespace App \Providers ;
44
5+ use App \Filament \Admin \Livewire \GlobalSearch ;
56use App \Http \Controllers \BaseController ;
67use App \Http \Responses \LogoutResponse ;
78use App \Libraries \Discord ;
1819use Illuminate \Support \Facades \View ;
1920use Illuminate \Support \ServiceProvider ;
2021use Illuminate \Testing \ParallelTesting ;
22+ use Livewire \Livewire ;
2123use Spatie \Permission \PermissionRegistrar ;
2224use Whitecube \LaravelCookieConsent \Facades \Cookies ;
2325
@@ -60,6 +62,8 @@ public function boot()
6062 ->by ('discord-api-call ' );
6163 });
6264
65+ Livewire::component ('filament.livewire.global-search ' , GlobalSearch::class);
66+
6367 Cookies::essentials ()
6468 ->session ()
6569 ->csrf ();
You can’t perform that action at this time.
0 commit comments