Improved use of de-normed locations fields

This commit is contained in:
snipe
2017-10-30 19:21:35 -07:00
parent 4eee7f8d97
commit 7f1b962e56
4 changed files with 14 additions and 10 deletions
@@ -21,8 +21,10 @@ class LocationsController extends Controller
public function index(Request $request)
{
$this->authorize('view', Location::class);
$allowed_columns = ['id','name','address','address2','city','state','country','zip','created_at',
'updated_at','parent_id', 'manager_id','image'];
$allowed_columns = [
'id','name','address','address2','city','state','country','zip','created_at',
'updated_at','parent_id', 'manager_id','image',
'rtd_assets_count','users_count','assets_count'];
$locations = Location::with('parent', 'manager', 'childLocations')->select([
'locations.id',
@@ -39,8 +41,7 @@ class LocationsController extends Controller
'locations.updated_at',
'locations.image',
'locations.currency'
])->withCount('locationAssets')
->withCount('assignedAssets')
])->withCount('rtd_assets')
->withCount('assets')
->withCount('users');