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