Array to String

I'm trying to use a pivot table and I get this error here's the flare: https://flareapp.io/share/lm2KAqOP and also attached are my models and form
Flare
Array to string conversion - The error occurred at http://192.168.1.58/employees/create
No description
No description
No description
4 Replies
ModestasV
ModestasV10mo ago
Please read the #✅┊rules and avoid code screenshots As for the error - there is one of the fields that returns an array for whatever reason. I would suspect the selects for department, so try to debug them to see what they return
The Huntsman
The Huntsman10mo ago
my bad sorry about that. how would I check? that I'm new to this , this is what's in the request body:
"updates": {
"data.eid": "000000001",
"data.contact_number": "+971500000000",
"data.position": "Systems Administrator",
"data.active": true,
"data.employee_department.dept_id": "1",
"data.employee_department.supervisor": true
},
"calls": [
{
"path": null,
"method": "create",
"params": []
"updates": {
"data.eid": "000000001",
"data.contact_number": "+971500000000",
"data.position": "Systems Administrator",
"data.active": true,
"data.employee_department.dept_id": "1",
"data.employee_department.supervisor": true
},
"calls": [
{
"path": null,
"method": "create",
"params": []
ModestasV
ModestasV10mo ago
Oh, okay. This happens on update (missed that!) The reason this happens is that it attempts to set the employee_department as array. Imagine this code: $employee->departments()->attach(['dept_id' => 1, 'supervisor' => true]) To fix this, you need to look at https://filamentphp.com/docs/3.x/panels/resources/relation-managers#creating-with-pivot-attributes and most likely change how the form is defined. Can't help there exactly as I didn't do much work with many to many and pivots 😦
The Huntsman
The Huntsman10mo ago
Please ensure that any pivot attributes are listed in the withPivot() method of the relationship and inverse relationship.
So does that mean I have to list all pivot table columns using the withPivot() method? Also that part of the documentation is very uninformative 😥