From 39450c1fe9d35c33e7184f117438be83a6263145 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 2 Aug 2016 01:23:53 -0700 Subject: [PATCH] Eager load throttle query --- app/Http/Controllers/UsersController.php | 2 +- app/Models/User.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php index 7866df1951..38eca97985 100755 --- a/app/Http/Controllers/UsersController.php +++ b/app/Http/Controllers/UsersController.php @@ -876,7 +876,7 @@ class UsersController extends Controller } $users = User::select(array('users.id','users.employee_num','users.email','users.username','users.location_id','users.manager_id','users.first_name','users.last_name','users.created_at','users.notes','users.company_id', 'users.deleted_at','users.activated')) - ->with('assets', 'accessories', 'consumables', 'licenses', 'manager', 'groups', 'userloc', 'company'); + ->with('assets', 'accessories', 'consumables', 'licenses', 'manager', 'groups', 'userloc', 'company','throttle'); $users = Company::scopeCompanyables($users); switch ($status) { diff --git a/app/Models/User.php b/app/Models/User.php index 69facdb00c..c6b0d6db15 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -232,10 +232,10 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon public function accountStatus() { - if ($this->sentryThrottle) { - if ($this->sentryThrottle->suspended==1) { + if ($this->throttle) { + if ($this->throttle->suspended==1) { return 'suspended'; - } elseif ($this->sentryThrottle->banned==1) { + } elseif ($this->throttle->banned==1) { return 'banned'; } else { return false; @@ -262,7 +262,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon ->orderBy('created_at', 'desc'); } - public function sentryThrottle() + public function throttle() { return $this->hasOne('\App\Models\Throttle'); }