mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #6243 from turbo124/v5-develop
Cache timezones and languages
This commit is contained in:
commit
6b078861f4
@ -16,6 +16,7 @@ use App\Models\Presenters\CompanyPresenter;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Services\Notification\NotificationService;
|
use App\Services\Notification\NotificationService;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
|
use App\Utils\Traits\AppSetup;
|
||||||
use App\Utils\Traits\CompanySettingsSaver;
|
use App\Utils\Traits\CompanySettingsSaver;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use App\Utils\Traits\ThrottlesEmail;
|
use App\Utils\Traits\ThrottlesEmail;
|
||||||
@ -31,6 +32,7 @@ class Company extends BaseModel
|
|||||||
use MakesHash;
|
use MakesHash;
|
||||||
use CompanySettingsSaver;
|
use CompanySettingsSaver;
|
||||||
use ThrottlesEmail;
|
use ThrottlesEmail;
|
||||||
|
use AppSetup;
|
||||||
|
|
||||||
const ENTITY_RECURRING_INVOICE = 'recurring_invoice';
|
const ENTITY_RECURRING_INVOICE = 'recurring_invoice';
|
||||||
const ENTITY_CREDIT = 'credit';
|
const ENTITY_CREDIT = 'credit';
|
||||||
@ -311,7 +313,17 @@ class Company extends BaseModel
|
|||||||
|
|
||||||
public function timezone()
|
public function timezone()
|
||||||
{
|
{
|
||||||
return Timezone::find($this->settings->timezone_id);
|
|
||||||
|
$timezones = Cache::get('timezones');
|
||||||
|
|
||||||
|
if(!$timezones)
|
||||||
|
$this->buildCache(true);
|
||||||
|
|
||||||
|
return $timezones->filter(function ($item) {
|
||||||
|
return $item->id == $this->settings->timezone_id;
|
||||||
|
})->first();
|
||||||
|
|
||||||
|
// return Timezone::find($this->settings->timezone_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function designs()
|
public function designs()
|
||||||
@ -339,7 +351,18 @@ class Company extends BaseModel
|
|||||||
*/
|
*/
|
||||||
public function language()
|
public function language()
|
||||||
{
|
{
|
||||||
return Language::find($this->settings->language_id);
|
|
||||||
|
$languages = Cache::get('languages');
|
||||||
|
|
||||||
|
if(!$languages)
|
||||||
|
$this->buildCache(true);
|
||||||
|
|
||||||
|
return $languages->filter(function ($item) {
|
||||||
|
return $item->id == $this->settings->language_id;
|
||||||
|
})->first();
|
||||||
|
|
||||||
|
|
||||||
|
// return Language::find($this->settings->language_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocale()
|
public function getLocale()
|
||||||
|
@ -48,7 +48,7 @@ trait AppSetup
|
|||||||
$orderBy = 'num_days';
|
$orderBy = 'num_days';
|
||||||
} elseif ($name == 'fonts') {
|
} elseif ($name == 'fonts') {
|
||||||
$orderBy = 'sort_order';
|
$orderBy = 'sort_order';
|
||||||
} elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) {
|
} elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks', 'timezones'])) {
|
||||||
$orderBy = 'name';
|
$orderBy = 'name';
|
||||||
} else {
|
} else {
|
||||||
$orderBy = 'id';
|
$orderBy = 'id';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user