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
Is it a belongsToMany relationship?
Yes, this is a belongsToMay relationship
Are you using a Select multiple with relationship?
https://filamentphp.com/docs/3.x/forms/fields/select/#integrating-with-an-eloquent-relationship
share the model with this relationship
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.
I used hasOne but it threw me an error Calling undefined method Illuminate\Database\Eloquent\Relations\HasOne::associate()
1 company has 1 contact ?
no, it's about 1 company having more contacts
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
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.