1 Reply
Select::make('country_id')
->required()
->reactive()
->disabledOn('edit')
->afterStateUpdated(fn(Set $set) => $set('provinces', null))
->native(false)
->options(Country::all()->pluck('name' ,'id')),
Forms\Components\CheckboxList::make('provinces')
->visible(fn($get) => $get('country_id'))
->columnSpanFull()
->searchable()
->bulkToggleable()
->columns(3)
->relationship('provinces', 'name', function ($query, $get) {
if($get('country_id')) {
return $query->where('country_id', $get('country_id'));
}
return $query;
}),
Select::make('country_id')
->required()
->reactive()
->disabledOn('edit')
->afterStateUpdated(fn(Set $set) => $set('provinces', null))
->native(false)
->options(Country::all()->pluck('name' ,'id')),
Forms\Components\CheckboxList::make('provinces')
->visible(fn($get) => $get('country_id'))
->columnSpanFull()
->searchable()
->bulkToggleable()
->columns(3)
->relationship('provinces', 'name', function ($query, $get) {
if($get('country_id')) {
return $query->where('country_id', $get('country_id'));
}
return $query;
}),