Relationship not saving on update
Forms\Components\Select::make('locations')
->multiple()
->relationship('locations', 'name')
->preload()
->searchable()
->createOptionForm([
Forms\Components\Select::make('resort_id')
->relationship('resort', 'name')
->required()
->preload()
->searchable(),
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('slug')
->required()
->maxLength(255),
Forms\Components\TextInput::make('address')
->maxLength(255),
Forms\Components\TextInput::make('maps_url')
->url()
->maxLength(255),
Forms\Components\TextInput::make('what3words')
->maxLength(255),
]),
Forms\Components\Select::make('locations')
->multiple()
->relationship('locations', 'name')
->preload()
->searchable()
->createOptionForm([
Forms\Components\Select::make('resort_id')
->relationship('resort', 'name')
->required()
->preload()
->searchable(),
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('slug')
->required()
->maxLength(255),
Forms\Components\TextInput::make('address')
->maxLength(255),
Forms\Components\TextInput::make('maps_url')
->url()
->maxLength(255),
Forms\Components\TextInput::make('what3words')
->maxLength(255),
]),
/**
* The locations that belong to the product.
*
* @return BelongsToMany
*/
public function locations(): BelongsToMany
{
return $this->belongsToMany(Location::class);
}
/**
* The locations that belong to the product.
*
* @return BelongsToMany
*/
public function locations(): BelongsToMany
{
return $this->belongsToMany(Location::class);
}
Solution:Jump to solution
Oh, im dump. I was accidentally syncing an empty array somewhere else in my code. Oof
1 Reply
Solution
Oh, im dump. I was accidentally syncing an empty array somewhere else in my code. Oof