Is a relationship manager required to insert/update pivot table data?

What I am trying to do: I have a multi-tenant app that allows homeowners to manage their home maintenance tasks and Vendors. "Property" is the tenancy model. I have two models in a Many-to-Many relationship: Property and Vendor. I want the user to be able to update a "notes" field on the property_user pivot table. Must I use a relationship manager, or can this be done in the normal VendorResource create/edit form? What I did: I have the "withPivot(['notes']) setup on both Property and Vendor model. I added a "notes" textarea in my VendorResource.php My issue/the error: The application tries to insert the "notes" data into the Vendors table instead of the property_vendor pivot table. SQLSTATE[42S22]: Column not found: 1054 Unknown column 'notes' in 'field list' Code: VendorResource.php
Forms\Components\RichEditor::make('notes')
->columnSpan(2)
->nullable(),
Forms\Components\RichEditor::make('notes')
->columnSpan(2)
->nullable(),
Models/Vendor.php public function properties() { return $this->belongsToMany(Property::class, 'property_vendor')->withPivot(['notes']); } Model/Property.php public function vendors(): BelongsToMany { return $this->belongsToMany(Vendor::class, 'property_vendor')->withPivot(['notes']); }
1 Reply
Haydra
Haydra2mo ago
same problem, did you find something ?