Loading foreign key value while update

This commit is contained in:
dhanabalan
2025-04-01 16:16:37 +05:30
parent 6160d91357
commit a8b34fe1f3
6 changed files with 207 additions and 212 deletions

View File

@@ -8,6 +8,7 @@ use App\Models\Shift;
use Carbon\Carbon;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\ImportAction;
@@ -37,6 +38,7 @@ class ShiftResource extends Resource
->required()
// ->nullable()
->reactive()
->disabled(fn (Get $get) => !empty($get('id')))
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
@@ -60,6 +62,7 @@ class ShiftResource extends Resource
->required()
// ->nullable()
->reactive()
->disabled(fn (Get $get) => !empty($get('id')))
// ->options(fn (callable $get) =>
// \App\Models\Block::where('plant_id', $get('plant_id'))
// ->pluck('name', 'id')
@@ -203,6 +206,9 @@ class ShiftResource extends Resource
])
->hint(fn ($get) => $get('sEndTimeError') ? $get('sEndTimeError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
])
->columns(2),
]);