Well your table is defined to not accept null values in the address column.
And most probably when the user is submitting the form you are handling, they are not filling anything on the new_adress field.
You can either:
- Add validation to prevent blank
new_adress values
- Add a default value (could be an empty string) when retrieving the
new_address value from the request.
Option 1 would something like this:
request()->validate([
'new_address' => ['required'],
// add rules for other fields
]);
$data = Detail::find($id);
$data->company_name = request('new_company_name');
$data->address = request('new_address');
$data->place = request('new_place');
$data->country = request('new_country');
$data->company_email = request('new_company_email');
$data->company_phone = request('new_company_phone');
$data->save();
You can add similar validation rules to any other require field. When any validation rule fails, the user is redirected back to the form, and you can show the user validation errors.
You can read more about Validation, and how to display validation errors, on the docs:
https://laravel.com/docs/8.x/validation
Option 2 would something like this:
$data = Detail::find($id);
$data->company_name = request('new_company_name');
// second parameter is the default value
// in this case an empty string
$data->address = request('new_address', '');
$data->place = request('new_place');
$data->country = request('new_country');
$data->company_email = request('new_company_email');
$data->company_phone = request('new_company_phone');
$data->save();
Note I just added a default value for the column the error message is referring to. Add default values to any columns that don't accept NULL.
The default value can be anything you want, if you find an empty string misleading you could try something like this:
$data->address = request('new_address', 'Not informed');
Hope it helps.