theProfit's avatar

Laravel Nova with UUID

i get this error in my laravel application i now made it with UUID's

[previous exception] [object] (PDOException(code: 01000): SQLSTATE[01000]: Warning: 1265 Data truncated for column 'model_id' at row 1 at

The error in my nova i get:

SQLSTATE[01000]: Warning: 1265 Data truncated for column 'model_id' at row 1 (Connection: mysql, SQL: insert into ' action_events' (' batch _id' , ' user_ids , ' name' , ' actionable_types , ' actionable_ids , 'target_type', ' target_ids , ' model_ty pes , ' model_ici , 'fields', ' original', ' changes', ' status', ' exception', ' updated_ats , ' created_ats ) values (9d328a48-3e45-470f-b029-ac5fde585f9a, 63dd2b10-f0fc-4923-9bd4-b9f9f0fb5efe, Create, App\Models\Company, 9d328a48-3db a-446a-86ed-1dff5a86d474, App\Models\Company, 9d328a48-3dba-446a-86ed-1dff5a86d474, App\Models\Company, 9d328a48-3dba-446a-86ed-1dff5a86d474, ?, {"name":"ddd","id":"9d328a48-3dba-446a-86ed-1dff5a86d474","updat ed_at":"2024-10-08T16:12:19.000000Z","created_at":"2024-10-08T16:12:19.000000Z1, finished„ 2024-10-08 16:12:19, 2024-10-08 16:12:19)) 
There was a problem submitting the form.

And this is my action_events:

i can't find the problem, what do i do rong?

0 likes
3 replies
Jsanwo64's avatar

The issue you're encountering is related to the data type mismatch between your database schema and the data being inserted.

From the schema you shared, the model_id column is set to either uuid or unsignedBigInteger based on Builder::$defaultMorphKeyType. The error you're seeing (Data truncated for column 'model_id') suggests that the data being inserted into this column does not match the column definition.

theProfit's avatar

@jsanwo64 Thank you for your response. I understand your point. I switched from using IDs to UUIDs; however, I haven’t made any changes to the action_events table. Unfortunately, Laravel Nova lacks documentation regarding the use of UUIDs.

Additionally, I’ve noticed that the model_id field is too small to accommodate the UUID format. What would be the best way to resolve this issue?

jdc1898's avatar

@theProfit - Can you just change the size of the column in your database? Just change it to 36 characters.

Please or to participate in this conversation.