From 90fe8e9e82a8100792f4f38ad7ec9437f785addc Mon Sep 17 00:00:00 2001 From: Alex Popa Date: Mon, 30 Dec 2024 15:47:21 +0200 Subject: [PATCH] Filter specialist by status in case team --- .../Widgets/ListSpecialistsWidget.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Widgets/ListSpecialistsWidget.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Widgets/ListSpecialistsWidget.php index 9bf65eae..81398315 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Widgets/ListSpecialistsWidget.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Widgets/ListSpecialistsWidget.php @@ -63,7 +63,7 @@ public function table(Table $table): Table EditAction::make() ->form($this->getFormSchema()) ->fillForm(function (Specialist $record) { - if (!$record->role_id) { + if (! $record->role_id) { $record->role_id = -1; } @@ -128,7 +128,7 @@ public function getFormSchema(): array ->label(__('beneficiary.section.specialists.labels.name')) ->options( function (Get $get, $state) { - $roleID = (int)$get('role_id'); + $roleID = (int) $get('role_id'); if ($roleID === -1) { if ($state) { return [$state => User::find($state)->full_name]; @@ -155,7 +155,11 @@ function (Get $get, $state) { fn (Specialist $specialist) => $specialist->role_id === (int) $get('role_id') && $specialist->user_id !== $record?->user_id ) ->map(fn (Specialist $specialist) => $specialist->user_id) - ->contains($value) + ->contains($value) || + ! User::query() + ->find($value) + ->userStatus + ->isActive() ) ->searchable() ->preload()