Code refactoring.

This commit is contained in:
EnesSacid-Buker 2022-06-03 17:57:57 +03:00 committed by GitHub
parent 0f637ebda7
commit 7407747294
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,7 +45,7 @@ abstract class Factory extends BaseFactory
public function company(int $id): static public function company(int $id): static
{ {
Cache::put('factory_company_id', $id, Date::now()->addHour(6)); Cache::put('state_company_id', $id, Date::now()->addHour(6));
return $this->state([ return $this->state([
'company_id' => $id, 'company_id' => $id,
@ -59,17 +59,13 @@ abstract class Factory extends BaseFactory
public function setCompany(): void public function setCompany(): void
{ {
$id = Cache::get('factory_company_id'); $state_id = Cache::get('state_company_id');
if (! is_null($id)) { $this->company = ! is_null($state_id) ? company($state_id) : $this->user->companies()->first();
$this->company = company($id);
} else {
$this->company = $this->user->companies()->first();
}
$this->company->makeCurrent(); $this->company->makeCurrent();
app('url')->defaults(['company_id' => company_id()]); app('url')->defaults(['company_id' => $this->company->id]);
} }
public function getRawAttribute($key) public function getRawAttribute($key)