F
Filament14mo ago
toeknee

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 Zeus14mo ago
ummmm filleable?!
toeknee
toekneeOP14mo 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
toekneeOP14mo ago
No description
toeknee
toekneeOP14mo 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.
Want results from more Discord servers?
Add your server