From c6c1116de99b791aad2e77fe43eddbaf3b374d89 Mon Sep 17 00:00:00 2001 From: Anthony F McInerney Date: Sat, 17 Oct 2020 21:12:43 +0100 Subject: [PATCH] service templates - move to blade - fix permisson lookup --- LibreNMS/Permissions.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/LibreNMS/Permissions.php b/LibreNMS/Permissions.php index 5c92805188..4d6ea8a762 100644 --- a/LibreNMS/Permissions.php +++ b/LibreNMS/Permissions.php @@ -184,6 +184,19 @@ class Permissions return $this->deviceGroupMap[$user_id]; } + /** + * Get a list of id of all service templates the user can access + * + * @param \App\Models\User|int $user + * @return \Illuminate\Support\Collection + */ + public function serviceTemplatesForUser($user = null) + { + return $this->getServiceTemplatePermissions($user) + ->where('user_id', $this->getUserId($user)) + ->pluck('id'); + } + /** * Get the cached data for device permissions. Use helpers instead. * @@ -232,15 +245,17 @@ class Permissions } /** - * Get a list of id of all service templates the user can access + * Get the cached data for port permissions. Use helpers instead. * - * @param \App\Models\User|int $user * @return \Illuminate\Support\Collection */ - public function serviceTemplatesForUser($user = null) + public function getServiceTemplatePermissions() { - return $this->getServiceTemplatePermissions($user) - ->pluck('id'); + if (is_null($this->serviceTemplatePermissions)) { + $this->portPermissions = DB::table('service_templates')->get(); + } + + return $this->portPermissions; } /**