From 0f637ebda78565d9f6fd8d11541bf37eb4ef3896 Mon Sep 17 00:00:00 2001 From: EnesSacid-Buker <73346401+EnesSacid-Buker@users.noreply.github.com> Date: Fri, 3 Jun 2022 17:51:22 +0300 Subject: [PATCH] Code refactoring. --- app/Abstracts/Factory.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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();