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),
]),Can anyone see anything noticable as to why the relationships aren't saving on an Update request? It works fine when creating. The relationship is a many to many
/**
* 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);
}And defined in the reverse also
Solution
Oh, im dump. I was accidentally syncing an empty array somewhere else in my code. Oof