Support the ongoing development of Laravel.io →
Requests Eloquent
Last updated 2 years ago.
0

By your migration, data is a not nullable field. If the data you're put as example is correct, the data field you are trying to insert contains an empty array. It maybe the reason for the integrity fail.

0

That right as luizpedone said

0

luizpedone said:

By your migration, data is a not nullable field. If the data you're put as example is correct, the data field you are trying to insert contains an empty array. It maybe the reason for the integrity fail.

I think there maybe some confusion on my end.

Were you referring to this data array in your comment?

[{stuff..., "data":[], ...more stuff}]

I am actually not trying to target or save just what is contained in this array but in the larger array which contains the json object. Here is another example with that field filling in.

This is the Request Payload that the post request is sending

[{start: 2.75, end: 3.91, data: {note: "asdf"}, id: "wavesurfer_nu1g5d8"},…]
0: {start: 2.75, end: 3.91, data: {note: "asdf"}, id: "wavesurfer_nu1g5d8"}
1: {start: 5.44, end: 6.19, data: {note: "asdf"}, id: "wavesurfer_5lvi7ao"}

So, yes setting 'data' to nullable in my migration removes the error, however it still isn't receiving the payload.

What I'm wondering, is what am I targeting incorrectly, or calling incorrectly that is preventing my json array from being stored into my migration.

0

Max, I think your issue is that you're trying to save an array of objects on database.

Looking at your POST data, you have an array of objects which contains a data param containing arrays. So, to insert these values to database, you must iterate thought these arrays in order to get its data.

For example, if you want to get the first object data param, you should access it as $data[0]['data'].

Other issue you might be having is that your POST JSON data is incorrect (at least the one you posted here). Make sure it's correctly formatted before parsing it (you may dump the \Request::all() to see if it's being converted to a PHP array properly).

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

maxehnert maxehnert Joined 28 Apr 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.