More compact user code

This commit is contained in:
snipe 2016-03-25 17:45:50 -07:00
parent bd1cb921fc
commit 46a76e2c55

View file

@ -374,18 +374,15 @@ class LocationsController extends Controller
public function getDataViewUsers($locationID) public function getDataViewUsers($locationID)
{ {
$location = Location::find($locationID); $location = Location::find($locationID);
$location_users = $location->users;
$count = $location_users->count();
$rows = array(); $rows = array();
foreach ($location_users as $user) { foreach ($location->users as $user) {
$rows[] = array( $rows[] = array(
'name' => (string)link_to('/admin/users/'.$user->id.'/view', e($user->fullName())) 'name' => (string)link_to('/admin/users/'.$user->id.'/view', e($user->fullName()))
); );
} }
$data = array('total' => $count, 'rows' => $rows); $data = array('total' => $location->users->count(), 'rows' => $rows);
return $data; return $data;
} }
@ -413,7 +410,6 @@ class LocationsController extends Controller
'asset_tag' => e($asset->asset_tag), 'asset_tag' => e($asset->asset_tag),
'serial' => e($asset->serial), 'serial' => e($asset->serial),
'model' => e($asset->model->name), 'model' => e($asset->model->name),
); );
} }