diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index d42b5e6356..4a364bc07a 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -281,7 +281,7 @@ class Import implements ShouldQueue $modified = $resource; unset($modified['id']); - $user = $user_repository->save($modified, $this->fetchUser($resource['email']), true); + $user = $user_repository->save($modified, $this->fetchUser($resource['email']), true, false); $user_agent = array_key_exists('token_name', $resource) ?: request()->server('HTTP_USER_AGENT'); diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index 2bffa773fe..ef6f422abd 100644 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -45,12 +45,24 @@ class UserRepository extends BaseRepository * * @return user|\App\Models\user|null user Object */ - public function save(array $data, User $user, $is_migrating = false) + public function save(array $data, User $user, $is_migrating = false, $unset_company_user = false) { + $details = $data; + + /** + * Getting: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'company_user' + * because of User::unguard(). + * Solution. Unset company_user per request. + */ + + if ($unset_company_user) { + unset($details['company_user']); + } + $company = auth()->user()->company(); $account_id = $company->account->id; - $user->fill($data); + $user->fill($details); $user->account_id = $account_id; $user->save();