]> _ Git - cubedesigners_userdatabase.git/commitdiff
wip #5127 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 28 Feb 2022 15:49:33 +0000 (16:49 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 28 Feb 2022 15:49:33 +0000 (16:49 +0100)
src/app/Models/User.php

index e157a4874ff309ab99977e3a5a17669fc83ae514..e27f5e697c5205cc25f4f24d562b467b85f35cc4 100644 (file)
@@ -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;
         }