1

既に存在する場合は user_id に対してレコードを更新し、laravel の user_id に対して存在しない場合は新しいレコードを挿入しようとしています:

しかし、私のユーザー ID は $doctorProfile['user_id'] 内にあります データは挿入されていますが、ユーザー 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();

        }
4

1 に答える 1