From fe6d837123aa1d6d49b1a0236c6d8a2a00a2474f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 5 Jun 2024 14:48:51 +1000 Subject: [PATCH] move statics into container --- app/Models/Company.php | 30 +++++++++++++++++------------- config/app.php | 2 +- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/app/Models/Company.php b/app/Models/Company.php index e83c465cef79..8a276ac3ac76 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -636,17 +636,19 @@ class Company extends BaseModel public function country() { - $companies = Cache::get('countries'); + $countries = app('countries'); - if (! $companies) { - $this->buildCache(true); + // $countries = Cache::get('countries'); - $companies = Cache::get('countries'); - } + // if (! $companies) { + // $this->buildCache(true); - return $companies->filter(function ($item) { + // $companies = Cache::get('countries'); + // } + + return $countries->first(function ($item) { return $item->id == $this->getSetting('country_id'); - })->first(); + }); // return $this->belongsTo(Country::class); // return Country::find($this->settings->country_id); @@ -659,15 +661,17 @@ class Company extends BaseModel public function timezone() { - $timezones = Cache::get('timezones'); + // $timezones = Cache::get('timezones'); - if (! $timezones) { - $this->buildCache(true); - } + $timezones = app('timezones'); - return $timezones->filter(function ($item) { + // if (! $timezones) { + // $this->buildCache(true); + // } + + return $timezones->first(function ($item) { return $item->id == $this->settings->timezone_id; - })->first(); + }); // return Timezone::find($this->settings->timezone_id); } diff --git a/config/app.php b/config/app.php index 6caa54bcbe71..ddeb918ec94a 100644 --- a/config/app.php +++ b/config/app.php @@ -201,7 +201,7 @@ return [ App\Providers\MultiDBProvider::class, App\Providers\ClientPortalServiceProvider::class, App\Providers\NinjaTranslationServiceProvider::class, - App\Providers\StaticServiceProvider::class, + App\Providers\StaticServiceProvider::class, ], /*