Related record, pivot extra column values

I'm trying to understand what happens in save over with this:
Forms\Components\BelongsToManyMultiSelect::make('role') ->multiple() ->relationship('role','title',fn($query) => $query->where('title','!=','Super Admin')) ->options(Roles::all()->pluck('title', 'id')->toArray()), It seems none of the model defaults are run, but the insert is raw SQL, so it's rather hard to hook into it to put some default values in place. Any pointers? ps. was trying to understand this through form components/Select.php, which has this nice 400 line Christmas tree method called "relationship" without really too relevant comments. Uh. Any clue as to why the whole Filament source code is largely undocumented?
1 Reply
Timster8989
Timster8989OP14mo ago
For anyone else stumbling here, here would be how to do it via the relation definition: public function role() { return $this->belongsToMany(\App\Models\BaseModels\Bouncer\Roles::class,'assigned_roles','entity_id','role_id','id','id')->withPivotValue('entity_type','App\Models\User'); }
Want results from more Discord servers?
Add your server