From 052b779e67c8920894da1cde575c6241438b30f8 Mon Sep 17 00:00:00 2001 From: Sydgren Date: Thu, 10 Dec 2020 10:15:00 +0100 Subject: [PATCH] Fix memory usage when listing roles increasing with user count --- src-php/Role.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src-php/Role.php b/src-php/Role.php index 0119e3b..d7e273b 100644 --- a/src-php/Role.php +++ b/src-php/Role.php @@ -40,10 +40,6 @@ class Role extends Resource 'name', ]; - public static $with = [ - 'users', - ]; - /** * Get the fields displayed by the resource. * @@ -73,7 +69,7 @@ public function fields(Request $request) ->toArray()), Text::make(__('Users'), function () { - return count($this->users); + return $this->users()->count(); })->onlyOnIndex(), BelongsToMany::make(__('Users'), 'users', config('novatoolpermissions.userResource', 'App\Nova\User'))