Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed May 15, 2021
1 parent 93a23d9 commit 43c32b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
6 changes: 3 additions & 3 deletions app/Jobs/Auth/CreateUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public function handle()
}

if ($this->request->has('companies')) {
if (request()->isNotInstall()) {
if (app()->runningInConsole() || request()->isInstall()) {
$this->user->companies()->attach($this->request->get('companies'));
} else {
$user = user();

$companies = $user->withoutEvents(function () use ($user) {
Expand All @@ -62,8 +64,6 @@ public function handle()
if ($companies->isNotEmpty()) {
$this->user->companies()->attach($companies->toArray());
}
} else {
$this->user->companies()->attach($this->request->get('companies'));
}
}

Expand Down
20 changes: 12 additions & 8 deletions app/Jobs/Auth/UpdateUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@ public function handle()
}

if ($this->request->has('companies')) {
$user = user();

$companies = $user->withoutEvents(function () use ($user) {
return $user->companies()->whereIn('id', $this->request->get('companies'))->pluck('id');
});

if ($companies->isNotEmpty()) {
$this->user->companies()->sync($companies->toArray());
if (app()->runningInConsole() || request()->isInstall()) {
$this->user->companies()->attach($this->request->get('companies'));
} else {
$user = user();

$companies = $user->withoutEvents(function () use ($user) {
return $user->companies()->whereIn('id', $this->request->get('companies'))->pluck('id');
});

if ($companies->isNotEmpty()) {
$this->user->companies()->sync($companies->toArray());
}
}
}

Expand Down

0 comments on commit 43c32b7

Please sign in to comment.