Changes
This commit is contained in:
+43
-32
@@ -35,38 +35,49 @@ class ImportUsers implements ShouldQueue
|
||||
foreach ($response as $user) {
|
||||
$userDetail = $user->user_detail;
|
||||
unset($user->user_detail);
|
||||
$user = User::create([
|
||||
'name' => $user->name,
|
||||
'slug' => $user->slug,
|
||||
'email' => $user->email,
|
||||
'email_verified_at' => $user->email_verified_at,
|
||||
'password' => Md5(Str::random(15)),
|
||||
'remember_token' => null,
|
||||
'created_at' => $user->created_at,
|
||||
'updated_at' => $user->updated_at,
|
||||
]);
|
||||
$user->userDetail()->create([
|
||||
'user_id' => $user->id,
|
||||
'is_only_worker' => $userDetail->is_only_worker,
|
||||
'photo' => $userDetail->photo,
|
||||
'academicTitle' => $userDetail->academicTitle,
|
||||
'AcademicDegree' => $userDetail->AcademicDegree,
|
||||
'education' => $userDetail->education,
|
||||
'awards' => $userDetail->awards,
|
||||
'professDisciplines' => $userDetail->professDisciplines,
|
||||
'professionalRetraining' => $userDetail->professionalRetraining,
|
||||
'professionalDevelopment' => $userDetail->professionalDevelopment,
|
||||
'workExperience' => $userDetail->workExperience,
|
||||
'attendedConferences' => $userDetail->attendedConferences,
|
||||
'participationScienceProjects' => $userDetail->participationScienceProjects,
|
||||
'publications' => $userDetail->publications,
|
||||
'contactEmail' => $userDetail->contactEmail,
|
||||
'contactPhone' => $userDetail->contactPhone,
|
||||
'search_data' => $userDetail->search_data,
|
||||
'other' => $userDetail->other,
|
||||
'created_at' => $userDetail->created_at,
|
||||
'updated_at' => $userDetail->updated_at,
|
||||
]);
|
||||
|
||||
// Проверяем, существует ли пользователь с данным email
|
||||
$existingUser = User::where('email', $user->email)->first();
|
||||
|
||||
if (!$existingUser) {
|
||||
// Если пользователь не найден, создаём его
|
||||
$newUser = User::create([
|
||||
'name' => $user->name,
|
||||
'slug' => $user->slug,
|
||||
'email' => $user->email,
|
||||
'email_verified_at' => $user->email_verified_at,
|
||||
'password' => md5(Str::random(15)), // Убедитесь, что хэширование пароля соответствует вашим стандартам
|
||||
'remember_token' => null,
|
||||
'created_at' => $user->created_at,
|
||||
'updated_at' => $user->updated_at,
|
||||
]);
|
||||
|
||||
// Создаем детали пользователя
|
||||
$newUser->userDetail()->create([
|
||||
'user_id' => $newUser->id,
|
||||
'is_only_worker' => $userDetail->is_only_worker,
|
||||
'photo' => $userDetail->photo,
|
||||
'academicTitle' => $userDetail->academicTitle,
|
||||
'AcademicDegree' => $userDetail->AcademicDegree,
|
||||
'education' => $userDetail->education,
|
||||
'awards' => $userDetail->awards,
|
||||
'professDisciplines' => $userDetail->professDisciplines,
|
||||
'professionalRetraining' => $userDetail->professionalRetraining,
|
||||
'professionalDevelopment' => $userDetail->professionalDevelopment,
|
||||
'workExperience' => $userDetail->workExperience,
|
||||
'attendedConferences' => $userDetail->attendedConferences,
|
||||
'participationScienceProjects' => $userDetail->participationScienceProjects,
|
||||
'publications' => $userDetail->publications,
|
||||
'contactEmail' => $userDetail->contactEmail,
|
||||
'contactPhone' => $userDetail->contactPhone,
|
||||
'search_data' => $userDetail->search_data,
|
||||
'other' => $userDetail->other,
|
||||
'created_at' => $userDetail->created_at,
|
||||
'updated_at' => $userDetail->updated_at,
|
||||
]);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Error fetching posts: ' . $e->getMessage());
|
||||
|
||||
Reference in New Issue
Block a user