From: Vincent Vanwaelscappel Date: Mon, 28 Feb 2022 15:49:33 +0000 (+0100) Subject: wip #5127 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=12b0f50ef76e91f80723b1c08c4b1d342d6f8f15;p=cubedesigners_userdatabase.git wip #5127 @1 --- 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; }