Hemanath
How to use $get and $set in custom page
Grid::make()
->schema([
Radio::make('yard_type')
->options(function () {
$yard = Master::where('parent_id', config('constants.master.yard_type'))->get()->pluck('display_name', 'display_name');
return $yard;
})->inline()->label('Yard Type')->required()
->afterStateUpdated(function (Set $set) {
$set('trip', null);
$set('mcc_id', null);
$set('vehicle_id', null);
})->reactive(),
]),
Grid::make()
->schema([
Select::make('mcc_id')->required()
->label('MCC')->placeholder('Type MCC Name')->autofocus()->preload()->searchable()->reactive()
->getSearchResultsUsing(fn (string $search) => Mcc::where('name', 'like', "%{$search}%")->pluck('name', 'id'))
->options(function () {
$mcc = Mcc::all();
return $mcc->pluck('name', 'id');
})->visible(function (Get $get) {
return $get('yard_type') == config('constants.yard_type.compost_yard') ? true : false;
}),
]), here is the code which i use get and set between two fields.
5 replies