Eager load throttle query

This commit is contained in:
snipe 2016-08-02 01:23:53 -07:00
parent 64ffd261fc
commit 39450c1fe9
2 changed files with 5 additions and 5 deletions

View file

@ -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')) $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); $users = Company::scopeCompanyables($users);
switch ($status) { switch ($status) {

View file

@ -232,10 +232,10 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
public function accountStatus() public function accountStatus()
{ {
if ($this->sentryThrottle) { if ($this->throttle) {
if ($this->sentryThrottle->suspended==1) { if ($this->throttle->suspended==1) {
return 'suspended'; return 'suspended';
} elseif ($this->sentryThrottle->banned==1) { } elseif ($this->throttle->banned==1) {
return 'banned'; return 'banned';
} else { } else {
return false; return false;
@ -262,7 +262,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
->orderBy('created_at', 'desc'); ->orderBy('created_at', 'desc');
} }
public function sentryThrottle() public function throttle()
{ {
return $this->hasOne('\App\Models\Throttle'); return $this->hasOne('\App\Models\Throttle');
} }