]> _ Git - cubedesigners_userdatabase.git/commitdiff
wip #3889 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 17 Sep 2020 07:31:32 +0000 (09:31 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 17 Sep 2020 07:31:32 +0000 (09:31 +0200)
src/User.php

index 0708bb0a944353c372c0c410ac018e2d1cd2912d..1fc9745a28545c5edd509c29e82133e306f46ca1 100644 (file)
@@ -59,7 +59,7 @@ class User extends CubistMagicAuthenticatable
             'type' => 'Locale',
             'tab' => 'Settings']);
 
-        $extranetv1 = ['settings', 'ws_password', 'ws_settings', 'ws_rights', 'ws_domains', 'login', 'mobile', 'fax', 'notes', 'grade','resetpassword'];
+        $extranetv1 = ['settings', 'ws_password', 'ws_settings', 'ws_rights', 'ws_domains', 'login', 'mobile', 'fax', 'notes', 'grade', 'resetpassword'];
 
         foreach ($extranetv1 as $f) {
             $this->addField(['name' => 'e1_' . $f,
@@ -98,18 +98,25 @@ class User extends CubistMagicAuthenticatable
 
     protected static function _getCompanyNames($id = null)
     {
-        if (null === self::$_companyNames) {
-            self::$_companyNames = Company::all()->pluck('name', 'id')->toArray();
-        }
+        $cacheKey = '_get_compagny_names';
+        start_measure($cacheKey, 'Get compagny names');
+        self::$_companyNames = cache()->tags(['model_' . Company::class])->remember($cacheKey, 86400, function () {
+            return Company::all()->pluck('name', 'id')->toArray();
+        });
+        stop_measure($cacheKey);
         if (null === $id) {
             return self::$_companyNames;
         }
+
         return self::$_companyNames[$id];
     }
 
     public function getManagedUsers()
     {
-        return Permissions::getManagedUsers($this->id);
+        start_measure('_get_managed_users', 'Get managed users');
+        $res = Permissions::getManagedUsers($this->id);
+        stop_measure('_get_managed_users');
+        return $res;
     }