Я пытаюсь обновить запись для user_id, если она уже существует, и вставить новую запись, если она не существует для user_id в laravel:
Но мой идентификатор пользователя находится внутри $ doctorProfile ['user_id']
данные вставляются, но идентификатор пользователя вставляется как NULL:
Код моего контроллера:
if($request->has('doctor_profile'))
{
$doctorProfile = $body['doctor_profile'];
$data_array = [
'user_id' => $doctorProfile['user_id'],
'medical_credentials' =>
$doctorProfile['medical_credentials'],
'registration_number' =>
$doctorProfile['registration_number'],
'registration_expiration_date' =>
$doctorProfile['registration_expiration_date'],
'dea_number' => $doctorProfile['dea_number'],
'dea_expiration_date' =>
$doctorProfile['dea_expiration_date'],
'dea_issue_date' => $doctorProfile['dea_issue_date'],
'npi_number' => $doctorProfile['npi_number'],
'billing_title' => $doctorProfile['billing_title'],
'billing_employment_type' =>
$doctorProfile['billing_employment_type'],
'other_employment_type' => $doctorProfile['other_employment_type'],
'nadean_number' => $doctorProfile['nadean_number'],
'upin' => $doctorProfile['upin'],
'wcb_authorization' => $doctorProfile['wcb_authorization'],
'wcb_rating_code' => $doctorProfile['wcb_rating_code'],
'wcb_date_of_issue' => $doctorProfile['wcb_date_of_issue'],
'hospital_privileges' => $doctorProfile['hospital_privileges'],
];
$medId = MedicalIdentifiers::firstOrCreate(['user_id' => $doctorProfile['user_id']], $data_array);
$medId->save();
}