|
13 | 13 | use App\Filament\Forms\Components\Household; |
14 | 14 | use App\Filament\Forms\Components\Location; |
15 | 15 | use App\Filament\Schemas\Components\Subsection; |
| 16 | +use App\Models\Beneficiary; |
16 | 17 | use App\Rules\ValidCNP; |
17 | 18 | use Filament\Forms\Components\Checkbox; |
18 | 19 | use Filament\Forms\Components\DatePicker; |
@@ -50,16 +51,41 @@ public static function configure(Schema $schema, bool $includeProgram = false): |
50 | 51 | TextEntry::make('type') |
51 | 52 | ->label(__('field.beneficiary_type')), |
52 | 53 |
|
53 | | - TextEntry::make('nurse.full_name') |
54 | | - ->label(__('field.allocated_nurse')), |
| 54 | + Select::make('nurse_id') |
| 55 | + ->label(__('field.allocated_nurse')) |
| 56 | + ->placeholder(__('placeholder.choose')) |
| 57 | + ->relationship( |
| 58 | + 'nurse', |
| 59 | + 'full_name', |
| 60 | + fn (Builder $query): Builder => $query |
| 61 | + ->onlyNurses() |
| 62 | + ->activatesInCurrentUserCounty() |
| 63 | + ->select([ |
| 64 | + 'id', 'full_name', |
| 65 | + ]) |
| 66 | + ) |
| 67 | + ->searchable() |
| 68 | + ->preload() |
| 69 | + ->visible(fn () => auth()->user()?->isMediator()) |
| 70 | + ->disabled(fn (Beneficiary $record): bool => filled($record->nurse_id)), |
55 | 71 |
|
56 | 72 | Select::make('mediator_id') |
57 | 73 | ->label(__('field.allocated_mediator')) |
58 | 74 | ->placeholder(__('placeholder.choose')) |
59 | | - ->relationship('mediator', 'full_name', fn (Builder $query) => $query->onlyMediators()) |
| 75 | + ->relationship( |
| 76 | + 'mediator', |
| 77 | + 'full_name', |
| 78 | + fn (Builder $query): Builder => $query |
| 79 | + ->onlyMediators() |
| 80 | + ->activatesInCurrentUserCounty() |
| 81 | + ->select([ |
| 82 | + 'id', 'full_name', |
| 83 | + ]) |
| 84 | + ) |
60 | 85 | ->searchable() |
61 | 86 | ->preload() |
62 | | - ->visible(fn () => auth()->user()?->isNurse()), |
| 87 | + ->visible(fn () => auth()->user()?->isNurse()) |
| 88 | + ->disabled(fn (Beneficiary $record): bool => filled($record->mediator_id)), |
63 | 89 |
|
64 | 90 | Select::make('integrated') |
65 | 91 | ->label(__('field.integrated')) |
|
0 commit comments