Skip to content

Commit

Permalink
Fix eager loading for user throttle
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Mar 17, 2015
1 parent c2c0196 commit c00086c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/config/version.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
return array (
'app_version' => 'v1.2.6.1-66',
'hash_version' => 'v1.2.6.1-66-g0ffb5df',
'app_version' => 'v1.2.6.1-67',
'hash_version' => 'v1.2.6.1-67-g3da6522',
);
2 changes: 1 addition & 1 deletion app/controllers/admin/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ public function postBulkSave($assets = null)
public function getDatatable($status = null)
{

$assets = Asset::with('model','assigneduser','assetstatus','defaultLoc','assetlog','model','model.category')->Hardware();
$assets = Asset::with('model','assigneduser','assetstatus','defaultLoc','assetlog','model','model.category','sentryThrottle')->Hardware();


switch ($status) {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ public function postImport()
public function getDatatable($status = null)
{

$users = User::with('assets','licenses','manager');
$users = User::with('assets','licenses','manager','sentryThrottle');

switch ($status) {
case 'deleted':
Expand Down
12 changes: 12 additions & 0 deletions app/models/Throttle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
class Throttle extends Elegant
{

protected $table = 'throttle';
public function user()
{
return $this->belongsTo('User', 'user_id');
}


}
25 changes: 15 additions & 10 deletions app/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,23 @@ public function manager()
{
return $this->belongsTo('User','manager_id')->withTrashed();
}



public function accountStatus()
{
$throttle = Sentry::findThrottlerByUserId($this->id);

if ($throttle->isBanned()) {
return 'banned';
} elseif ($throttle->isSuspended()) {
return 'suspended';
} else {
return '';
}
if ($this->sentryThrottle->suspended==1) {
return 'suspended';
} elseif ($this->sentryThrottle->banned==1) {
return 'banned';
} else {
return false;
}


}

public function sentryThrottle() {
return $this->hasOne('Throttle');
}

public function scopeGetDeleted($query)
Expand Down

0 comments on commit c00086c

Please sign in to comment.