Skip to content

Commit

Permalink
Merge pull request #113 from andrewdwallo/development
Browse files Browse the repository at this point in the history
update: SwitchCurrentCompany.php
  • Loading branch information
andrewdwallo committed Jan 3, 2024
2 parents 1fcfdda + 152c4ea commit 31bbf1f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Listeners/SwitchCurrentCompany.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ public function __construct()
public function handle(TenantSet $event): void
{
$tenant = $event->getTenant();

/** @var HasCompanies $user */
$user = $event->getUser();

if (Features::switchesCurrentCompany() === false || !in_array(HasCompanies::class, class_uses_recursive($user), true)) {
return;
}

if (! $user->isCurrentCompany($tenant)) {
$user->switchCompany($tenant);
if (! $user->switchCompany($tenant)) {
$user->switchCompany($user->personalCompany());
}
}
}

0 comments on commit 31bbf1f

Please sign in to comment.