Pivot not saving to db?

Thoughts on what might cause a select pivot not to save to the db? But manually entering to the DB loads it perfectly.
Forms\Components\Select::make('owningCompanies')
->label('Owning Company')
->relationship('owningCompanies', 'name')
->options(fn() => Company::select('name', 'id')->where('type', 'OWNING')->get()->pluck('name', 'id'))
->preload()
->multiple()
->maxItems(1)
->columnSpan(3),
Forms\Components\Select::make('owningCompanies')
->label('Owning Company')
->relationship('owningCompanies', 'name')
->options(fn() => Company::select('name', 'id')->where('type', 'OWNING')->get()->pluck('name', 'id'))
->preload()
->multiple()
->maxItems(1)
->columnSpan(3),
public function owningCompanies(): \Illuminate\Database\Eloquent\Relations\belongsToMany
{
return $this->belongsToMany(Company::class)->where('type', 'OWNING');
}

public function owningCompanies(): \Illuminate\Database\Eloquent\Relations\belongsToMany
{
return $this->belongsToMany(Company::class)->where('type', 'OWNING');
}

4 Replies
Lara Zeus
Lara Zeus9mo ago
ummmm filleable?!
toeknee
toeknee9mo ago
Filleable on a pivot? This is a schema form too. It does save but then it's deleted by the looks of it
toeknee
toeknee9mo ago
No description
toeknee
toeknee9mo ago
I know why, because I have two relationships using the same Companies table. But I have a where query on the belongsToMany that doesn't seem to be getting applied. So it inserts it, but the second field after owningCompanies is empty so deletes the records blugh.