Code refactoring.
This commit is contained in:
parent
0f637ebda7
commit
7407747294
@ -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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user