From 12b0f50ef76e91f80723b1c08c4b1d342d6f8f15 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 28 Feb 2022 16:49:33 +0100 Subject: [PATCH] wip #5127 @1 --- src/app/Models/User.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/app/Models/User.php b/src/app/Models/User.php index e157a48..e27f5e6 100644 --- a/src/app/Models/User.php +++ b/src/app/Models/User.php @@ -94,7 +94,7 @@ class User extends CubistMagicAuthenticatable 'type' => Integer::class, 'tab' => __('Chiffres'), 'column' => true, - 'read_only'=>true]); + 'read_only' => true]); $extranetv1 = ['settings', 'ws_password', 'ws_settings', 'ws_rights', 'ws_domains', 'ws_count', 'login', 'mobile', 'fax', 'notes', 'resetpassword']; @@ -149,14 +149,16 @@ class User extends CubistMagicAuthenticatable protected static function _getCompanyNames($id = null) { - $cacheKey = '_get_compagny_names'; - start_measure($cacheKey, 'Get compagny names'); - self::$_companyNames = cache()->tags(['model_' . Company::class])->remember($cacheKey, 86400, function () { - set_time_limit(0); - $res = Company::withoutGlobalScopes()->get(); - return $res->pluck('name', 'id')->toArray(); - }); - stop_measure($cacheKey); + if (null === self::$_companyNames) { + $cacheKey = '_get_compagny_names'; + start_measure($cacheKey, 'Get compagny names'); + self::$_companyNames = cache()->tags(['model_' . Company::class])->remember($cacheKey, 86400, function () { + set_time_limit(0); + $res = Company::withoutGlobalScopes()->get(); + return $res->pluck('name', 'id')->toArray(); + }); + stop_measure($cacheKey); + } if (null === $id) { return self::$_companyNames; } -- 2.39.5