F
Filament6mo ago
kisut

Array to String Conversion Problem

I'm building form that include Repeater, but when I'm trying to save the form, Array to String Conversion error always appears. I have ensured that the column in the database has JSON type. Is theres any solution?
No description
12 Replies
awcodes
awcodes6mo ago
You need to cast it in the model as ‘array’
kisut
kisutOP6mo ago
I do, but the error keeps coming.
protected $casts = [
'primary_artist' => 'array', 'featuring_artist' => 'array', 'metadata_track' => 'array',
];
protected $casts = [
'primary_artist' => 'array', 'featuring_artist' => 'array', 'metadata_track' => 'array',
];
error
Array to string conversion (Connection: pgsql, SQL: insert into "releases" ("user_id", "status_project", "release_link", "release_title", "cover_art", "genre_project", "format_project", "original_date", "release_date", "p_line", "c_line", "production_year", "upc_project", "content_id_exclude", "track_link", "metadata_track", "updated_at", "created_at") values (2, Pending, ?, Surga, ?, 4, 1, 2024-06-22, 2024-06-25, Exercitation velit , Ut sit et amet quo , 2024, 12312312, ?, Optio corrupti neq, [{"trackTitle":"surga","genre_track":"0","preview_track":"22:55","isrc_track":"13sadasdas","language_track":"AL","excplicit_track":["true"],"writer_track":["sadasdas"]}], 2024-06-05 19:17:05, 2024-06-05 19:17:05) returning "id")
Array to string conversion (Connection: pgsql, SQL: insert into "releases" ("user_id", "status_project", "release_link", "release_title", "cover_art", "genre_project", "format_project", "original_date", "release_date", "p_line", "c_line", "production_year", "upc_project", "content_id_exclude", "track_link", "metadata_track", "updated_at", "created_at") values (2, Pending, ?, Surga, ?, 4, 1, 2024-06-22, 2024-06-25, Exercitation velit , Ut sit et amet quo , 2024, 12312312, ?, Optio corrupti neq, [{"trackTitle":"surga","genre_track":"0","preview_track":"22:55","isrc_track":"13sadasdas","language_track":"AL","excplicit_track":["true"],"writer_track":["sadasdas"]}], 2024-06-05 19:17:05, 2024-06-05 19:17:05) returning "id")
awcodes
awcodes6mo ago
Never worked with Postgres but I wonder if it has something to do with the nested arrays.
kisut
kisutOP6mo ago
I still don't understand, do you have an example?
Dennis Koch
Dennis Koch6mo ago
I don't think there should be anything special to Postgres
awcodes
awcodes6mo ago
I don’t either. But the data looks ok to me.
slamx_
slamx_6mo ago
You set the casts right, we use also Postgres without problems. How do you setup the database field type?
toeknee
toeknee6mo ago
Did you add the casts to the releases model
kisut
kisutOP6mo ago
I do setup the
primary_artist
primary_artist
featuring_artist
featuring_artist
and
metadata_track
metadata_track
with json columns. So that's why I'm also confused why the result is actually an error. Yes, I do add the cast into releases model. Can you help me about this? I can give you access to see the code if that need.
toeknee
toeknee6mo ago
Provide the schema of the table
kisut
kisutOP6mo ago
Here is the database table and the model.
No description
No description
kisut
kisutOP6mo ago
Until now, no solution has been found...
Want results from more Discord servers?
Add your server