several fixes

This commit is contained in:
Denis Duliçi
2021-05-14 18:29:24 +03:00
parent 7ac53681ff
commit b8057a7a12
19 changed files with 165 additions and 75 deletions

View File

@ -52,7 +52,15 @@ class CreateUser extends Job
}
if ($this->request->has('companies')) {
$this->user->companies()->attach($this->request->get('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()->attach($companies->toArray());
}
}
if (empty($this->user->companies)) {