SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value:

Hi I have a problem with saving data to the database. SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '["1","2"]' for column crm.companies.contact_id at row 1.May I ask your advice please??
12 Replies
LeandroFerreira
LeandroFerreira11mo ago
Is it a belongsToMany relationship?
marty6236
marty6236OP11mo ago
Yes, this is a belongsToMay relationship
marty6236
marty6236OP11mo ago
No description
No description
LeandroFerreira
LeandroFerreira11mo ago
share the model with this relationship
LeandroFerreira
LeandroFerreira11mo ago
You told me that it was a belongsToMany relationship... you have two "contacts" and they aren't belongsToMany Check the relationships https://laravel.com/docs/10.x/eloquent-relationships#defining-relationships
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
marty6236
marty6236OP11mo ago
I used hasOne but it threw me an error Calling undefined method Illuminate\Database\Eloquent\Relations\HasOne::associate()
LeandroFerreira
LeandroFerreira11mo ago
1 company has 1 contact ?
marty6236
marty6236OP11mo ago
no, it's about 1 company having more contacts
LeandroFerreira
LeandroFerreira11mo ago
this should be HasMany or BelongsToMany, right? You should check the relationships in the link I sent and then create a relation manager in the Filament if you are using belongsToMany https://filamentphp.com/docs/3.x/panels/resources/relation-managers#attaching-and-detaching-records if you are using HasMany https://filamentphp.com/docs/3.x/panels/resources/relation-managers#associating-and-dissociating-records
marty6236
marty6236OP11mo ago
It already works, the correct solution was BelongToMany and create a new table in the company_contact database. Thank you for pointing out the correct solution.
Want results from more Discord servers?
Add your server