Laravel约束错误

After I filled in the dropdown menu with a forloop using the data of the inner join query that had been made. Everything was shown in the dropdown menu as it should. (company_name - task title). But when I press on save, my ajax throws an error which I will paste below.

<td> <select class='project_id'>@foreach($query as $data)<option>{!!  $data->company_name !!} - {!! $data->title !!}</option>@endforeach</td>

is the piece of code I use to loop through the query and to post the values in the dropdown menu

The printscreen of a part of the query and the values is posted below: enter image description hereThe error I get when I press the save button is.

enter image description here

If I check the object that gets sent via my ajax request. I see this:

enter image description here

You are not submitting the actual project id with the request which is needed.

Make sure the option value contains the project id and that is has the name set to project_id if that's what you are using on the server-side.

<td> <select class="project_id" name="project_id">@foreach($query as $data)<option value="{{ $data->id }}">{!!  $data->company_name !!} - {!! $data->title !!}</option>@endforeach</td>

Because you have a foreign key constraint, it says you want to add or update some project id which is not found in the projects table.