mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Migrate company_user with users (#3598)
This commit is contained in:
parent
28cc7d5e52
commit
6a0ddd6c38
@ -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');
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user