In my application, users can add their residential properties and create a listing based on that listing. Users can have many
- The Listing model relation
public function property(): BelongsTo
{
return $this->belongsTo(Property::class);
}
- The Property model relations
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function listing(): HasMany
{
return $this->hasMany(Listing::class);
}
- The field to select the property that the Listing is based on
Select::make('property_id')
->relationship('property', 'house_no')
->label('Stand Number')
->createOptionForm([
Section::make('Details')->schema([
Select::make('area')
->options([
"Bloomingdale" => "Bloomingdale",
'Ashdown Park' => "Ashdown Park"
]),
TextInput::make('house_no')
->required()
->label('House Number')
->numeric(),
TextInput::make('street')
->nullable(),
TextInput::make('families')
->label('Families On The Property')
->required()
->numeric(),
]),
My current setup of this field allows users that are not associated with the property to select it and associate it with their listing.
I want users’ property options to be limited to the ones they added. How do I do that?