From 063bc4c321b29af6a35d34b3ecbd4e56add32776 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 17 Sep 2020 09:31:32 +0200 Subject: [PATCH] wip #3889 @0.5 --- src/User.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/User.php b/src/User.php index 0708bb0..1fc9745 100644 --- a/src/User.php +++ b/src/User.php @@ -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; } -- 2.39.5