How to show / edit pivot attributes in a relation manager
I have two models
- Post Model
- Comment Model
Each of them has belongsToMany() relation
Note: Attaching and detaching are working fine
When I add the edit action
Laravel gives me this error
Filament\Resources\RelationManagers\RelationManager::Filament\Resources\RelationManagers{closure}(): Argument #1 ($record) must be of type Illuminate\Database\Eloquent\Model, null given
And is it possible to show pivot attributes along with model attattributes
2 Replies
We need more information to help you debug your problem. Please click on the top left 'SHARE' button of the error page you're seeing and share the link with us.
Sorry my bad π¦
I added the edit action to the headerActions
I deleted the pivot model
I deleted ->using('App\Models\PostCommect') from both model
I checked the relation function name lol
Post() it has to be post()
posts*
Comments() it has to be comments()
Now everything works fine
I used this to get the pivot attribute
and I used this to update the pivot attribute
I hope this helps someone π