Forms\Components\Select::make('property_type_id')
->relationship(name: 'propertyType', titleAttribute: 'name', modifyQueryUsing: function (Builder $query, Get $get) {
$query->whereHas('propertyCategories', function ($q) use ($get) {
$q->where('property_category_id', $get('property_category_id'));
});
})
->searchable()
->preload()
->live()
->afterStateUpdated(function (Set $set) {
$set('propertyAmenities', null);
})
->required(),
Forms\Components\Repeater::make('propertyPropertyTypeFeatures')
->relationship()
->schema([
Forms\Components\Select::make('property_type_feature_id')
->relationship('propertyTypeFeature', 'name', modifyQueryUsing: function (Builder $query, Get $get) {
$query->whereHas('propertyTypes', function ($q) use ($get) {
$q->where('property_type_id', $get('../../property_type_id'));
// $q->where('property_type_id', 1);
});
})
->live()
->afterStateUpdated(function (Set $set) {
$set('selected_feature_types', null);
})
->required(),
Forms\Components\TextInput::make('number')
->integer(),
Forms\Components\TextInput::make('max_number')
->integer(),
Forms\Components\Select::make('selected_feature_types')
->multiple()
->options(function (callable $get){
$selectOptions = PropertyTypeFeature::find($get('property_type_feature_id'));
if($selectOptions){
return $selectOptions->available_feature_type;
}
return null;
})
->preload()
->searchable(),
]),
Forms\Components\Select::make('property_type_id')
->relationship(name: 'propertyType', titleAttribute: 'name', modifyQueryUsing: function (Builder $query, Get $get) {
$query->whereHas('propertyCategories', function ($q) use ($get) {
$q->where('property_category_id', $get('property_category_id'));
});
})
->searchable()
->preload()
->live()
->afterStateUpdated(function (Set $set) {
$set('propertyAmenities', null);
})
->required(),
Forms\Components\Repeater::make('propertyPropertyTypeFeatures')
->relationship()
->schema([
Forms\Components\Select::make('property_type_feature_id')
->relationship('propertyTypeFeature', 'name', modifyQueryUsing: function (Builder $query, Get $get) {
$query->whereHas('propertyTypes', function ($q) use ($get) {
$q->where('property_type_id', $get('../../property_type_id'));
// $q->where('property_type_id', 1);
});
})
->live()
->afterStateUpdated(function (Set $set) {
$set('selected_feature_types', null);
})
->required(),
Forms\Components\TextInput::make('number')
->integer(),
Forms\Components\TextInput::make('max_number')
->integer(),
Forms\Components\Select::make('selected_feature_types')
->multiple()
->options(function (callable $get){
$selectOptions = PropertyTypeFeature::find($get('property_type_feature_id'));
if($selectOptions){
return $selectOptions->available_feature_type;
}
return null;
})
->preload()
->searchable(),
]),