diff --git a/app/Abstracts/Factory.php b/app/Abstracts/Factory.php index 1f14d9e8c..f633e9b8a 100644 --- a/app/Abstracts/Factory.php +++ b/app/Abstracts/Factory.php @@ -59,10 +59,12 @@ abstract class Factory extends BaseFactory public function setCompany(): void { - if (is_null(Cache::get('factory_company_id'))) { - $this->company = $this->user->companies()->first(); + $id = Cache::get('factory_company_id'); + + if (! is_null($id)) { + $this->company = company($id); } else { - $this->company = company(Cache::get('factory_company_id')); + $this->company = $this->user->companies()->first(); } $this->company->makeCurrent();