From b83f0055122994a79dc9267a6362f99a6a3fa26e Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 2 Jun 2026 09:26:22 +0530 Subject: [PATCH] Added other type option in filter --- .../Resources/VisitorEntryResource.php | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/app/Filament/Resources/VisitorEntryResource.php b/app/Filament/Resources/VisitorEntryResource.php index 4eb8318..ec63c3a 100644 --- a/app/Filament/Resources/VisitorEntryResource.php +++ b/app/Filament/Resources/VisitorEntryResource.php @@ -335,10 +335,15 @@ class VisitorEntryResource extends Resource 'GovermentOfficials' => 'Government Officials', 'Other' => 'Other', ]) - ->placeholder('Enter Type') + ->placeholder('Choose Type') ->afterStateUpdated(function ($state, callable $set, callable $get) { - $set('Rework', null); + $set('name', null); }), + TextInput::make('other_type') + ->label('Specify Type') + ->placeholder('Enter Type') + ->visible(fn (callable $get) => $get('type') == 'Other') + ->required(fn (callable $get) => $get('type') == 'Other'), TextInput::make('name') ->label('Visitor Name') ->reactive() @@ -386,7 +391,12 @@ class VisitorEntryResource extends Resource } if (! empty($data['type'])) { - $query->where('type', $data['type']); + if ($data['type'] == 'Other') { + $query->where('type', 'like', '%'.$data['other_type'].'%'); + } + else{ + $query->where('type', $data['type']); + } } if (! empty($data['name'])) { @@ -421,6 +431,10 @@ class VisitorEntryResource extends Resource $indicators[] = 'Type: '.$data['type']; } + if (! empty($data['other_type'])) { + $indicators[] = 'Specify Type: '.$data['other_type']; + } + if (! empty($data['name'])) { $indicators[] = 'Name: '.$data['name']; }