1
0
forked from poc/pds

Restrict update plant and item

This commit is contained in:
dhanabalan
2025-04-01 12:17:40 +05:30
parent a383aa00ed
commit 6160d91357

View File

@@ -7,6 +7,7 @@ use App\Filament\Resources\StickerMasterResource\RelationManagers;
use App\Models\StickerMaster; use App\Models\StickerMaster;
use Filament\Forms; use Filament\Forms;
use Filament\Forms\Form; use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Resources\Resource; use Filament\Resources\Resource;
use Filament\Tables; use Filament\Tables;
use Filament\Tables\Table; use Filament\Tables\Table;
@@ -31,6 +32,7 @@ class StickerMasterResource extends Resource
->relationship('plant', 'name') ->relationship('plant', 'name')
->reactive() ->reactive()
->nullable() ->nullable()
->disabled(fn (Get $get) => !empty($get('id')))
->afterStateUpdated(fn (callable $set) => ->afterStateUpdated(fn (callable $set) =>
$set('item_id', null) & $set('item_description', null) $set('item_id', null) & $set('item_description', null)
) )
@@ -51,6 +53,7 @@ class StickerMasterResource extends Resource
->nullable() ->nullable()
->searchable() ->searchable()
->reactive() ->reactive()
->disabled(fn (Get $get) => !empty($get('id')))
->live(debounce: 500) // Enable live updates ->live(debounce: 500) // Enable live updates
->afterStateUpdated(function ($state, callable $set, callable $get) { ->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id'); // Get selected plant_id $plantId = $get('plant_id'); // Get selected plant_id
@@ -180,6 +183,9 @@ class StickerMasterResource extends Resource
Forms\Components\Checkbox::make('warranty_card') Forms\Components\Checkbox::make('warranty_card')
->nullable() ->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null), ->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
]); ]);
} }