From c256536d2185b5437e2d8c04d9ea5a79e16faa07 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 3 Sep 2019 14:29:58 -0700 Subject: [PATCH] Math is hard --- app/Http/Controllers/Api/AccessoriesController.php | 2 +- app/Http/Controllers/Api/AssetMaintenancesController.php | 5 ++++- app/Http/Controllers/Api/AssetsController.php | 2 +- app/Http/Controllers/Api/CategoriesController.php | 2 +- app/Http/Controllers/Api/CompaniesController.php | 2 +- app/Http/Controllers/Api/ComponentsController.php | 2 +- app/Http/Controllers/Api/ConsumablesController.php | 2 +- app/Http/Controllers/Api/DepartmentsController.php | 2 +- app/Http/Controllers/Api/DepreciationsController.php | 2 +- app/Http/Controllers/Api/GroupsController.php | 2 +- app/Http/Controllers/Api/LicensesController.php | 2 +- app/Http/Controllers/Api/LocationsController.php | 2 +- app/Http/Controllers/Api/ManufacturersController.php | 2 +- app/Http/Controllers/Api/StatuslabelsController.php | 2 +- app/Http/Controllers/Api/SuppliersController.php | 2 +- app/Http/Controllers/Api/UsersController.php | 2 +- 16 files changed, 19 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/Api/AccessoriesController.php b/app/Http/Controllers/Api/AccessoriesController.php index b726407250..1cc57acebc 100644 --- a/app/Http/Controllers/Api/AccessoriesController.php +++ b/app/Http/Controllers/Api/AccessoriesController.php @@ -52,7 +52,7 @@ class AccessoriesController extends Controller $offset = (($accessories) && (request('offset') > $accessories->count())) ? 0 : request('offset', 0); // Check to make sure the limit is not higher than the max allowed - (config('app.max_results') < $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); + (config('app.max_results') >= $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; diff --git a/app/Http/Controllers/Api/AssetMaintenancesController.php b/app/Http/Controllers/Api/AssetMaintenancesController.php index e7584ec47a..28a9810063 100644 --- a/app/Http/Controllers/Api/AssetMaintenancesController.php +++ b/app/Http/Controllers/Api/AssetMaintenancesController.php @@ -45,7 +45,10 @@ class AssetMaintenancesController extends Controller } $offset = (($maintenances) && (request('offset') > $maintenances->count())) ? 0 : request('offset', 0); - $limit = request('limit', 50); + + // Check to make sure the limit is not higher than the max allowed + (config('app.max_results') >= $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); + $allowed_columns = [ 'id', diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 87cd59e668..aa1b013726 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -147,7 +147,7 @@ class AssetsController extends Controller $offset = (($assets) && (request('offset') > $assets->count())) ? 0 : request('offset', 0); // Check to make sure the limit is not higher than the max allowed - (config('app.max_results') < $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); + (config('app.max_results') >= $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; diff --git a/app/Http/Controllers/Api/CategoriesController.php b/app/Http/Controllers/Api/CategoriesController.php index e92f58625e..183837baf9 100644 --- a/app/Http/Controllers/Api/CategoriesController.php +++ b/app/Http/Controllers/Api/CategoriesController.php @@ -33,7 +33,7 @@ class CategoriesController extends Controller $offset = (($categories) && (request('offset') > $categories->count())) ? 0 : request('offset', 0); // Check to make sure the limit is not higher than the max allowed - (config('app.max_results') < $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); + (config('app.max_results') >= $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; $sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'assets_count'; diff --git a/app/Http/Controllers/Api/CompaniesController.php b/app/Http/Controllers/Api/CompaniesController.php index d9064cae16..d686a8aeca 100644 --- a/app/Http/Controllers/Api/CompaniesController.php +++ b/app/Http/Controllers/Api/CompaniesController.php @@ -44,7 +44,7 @@ class CompaniesController extends Controller $offset = (($companies) && (request('offset') > $companies->count())) ? 0 : request('offset', 0); // Check to make sure the limit is not higher than the max allowed - (config('app.max_results') < $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); + (config('app.max_results') >= $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; $sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at'; diff --git a/app/Http/Controllers/Api/ComponentsController.php b/app/Http/Controllers/Api/ComponentsController.php index 147cec1650..6638c0864f 100644 --- a/app/Http/Controllers/Api/ComponentsController.php +++ b/app/Http/Controllers/Api/ComponentsController.php @@ -46,7 +46,7 @@ class ComponentsController extends Controller $offset = (($components) && (request('offset') > $components->count())) ? 0 : request('offset', 0); // Check to make sure the limit is not higher than the max allowed - (config('app.max_results') < $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); + (config('app.max_results') >= $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); $allowed_columns = ['id','name','min_amt','order_number','serial','purchase_date','purchase_cost','company','category','qty','location','image']; $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; diff --git a/app/Http/Controllers/Api/ConsumablesController.php b/app/Http/Controllers/Api/ConsumablesController.php index 6e002ce66b..2fddcd0c8b 100644 --- a/app/Http/Controllers/Api/ConsumablesController.php +++ b/app/Http/Controllers/Api/ConsumablesController.php @@ -47,7 +47,7 @@ class ConsumablesController extends Controller $offset = (($consumables) && (request('offset') > $consumables->count())) ? 0 : request('offset', 0); // Check to make sure the limit is not higher than the max allowed - (config('app.max_results') < $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); + (config('app.max_results') >= $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); $allowed_columns = ['id','name','order_number','min_amt','purchase_date','purchase_cost','company','category','model_number', 'item_no', 'manufacturer','location','qty','image']; $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; diff --git a/app/Http/Controllers/Api/DepartmentsController.php b/app/Http/Controllers/Api/DepartmentsController.php index 8da3bd6a88..409e30c224 100644 --- a/app/Http/Controllers/Api/DepartmentsController.php +++ b/app/Http/Controllers/Api/DepartmentsController.php @@ -42,7 +42,7 @@ class DepartmentsController extends Controller $offset = (($departments) && (request('offset') > $departments->count())) ? 0 : request('offset', 0); // Check to make sure the limit is not higher than the max allowed - (config('app.max_results') < $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); + (config('app.max_results') >= $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; $sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at'; diff --git a/app/Http/Controllers/Api/DepreciationsController.php b/app/Http/Controllers/Api/DepreciationsController.php index d83d1deef7..c8cd92d155 100644 --- a/app/Http/Controllers/Api/DepreciationsController.php +++ b/app/Http/Controllers/Api/DepreciationsController.php @@ -31,7 +31,7 @@ class DepreciationsController extends Controller $offset = (($depreciations) && (request('offset') > $depreciations->count())) ? 0 : request('offset', 0); // Check to make sure the limit is not higher than the max allowed - (config('app.max_results') < $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); + (config('app.max_results') >= $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; $sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at'; diff --git a/app/Http/Controllers/Api/GroupsController.php b/app/Http/Controllers/Api/GroupsController.php index daa2972616..5cfed31be2 100644 --- a/app/Http/Controllers/Api/GroupsController.php +++ b/app/Http/Controllers/Api/GroupsController.php @@ -31,7 +31,7 @@ class GroupsController extends Controller $offset = (($groups) && (request('offset') > $groups->count())) ? 0 : request('offset', 0); // Check to make sure the limit is not higher than the max allowed - (config('app.max_results') < $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); + (config('app.max_results') >= $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; $sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at'; diff --git a/app/Http/Controllers/Api/LicensesController.php b/app/Http/Controllers/Api/LicensesController.php index b7ab3174d5..76bf9115a7 100644 --- a/app/Http/Controllers/Api/LicensesController.php +++ b/app/Http/Controllers/Api/LicensesController.php @@ -85,7 +85,7 @@ class LicensesController extends Controller $offset = (($licenses) && (request('offset') > $licenses->count())) ? 0 : request('offset', 0); // Check to make sure the limit is not higher than the max allowed - (config('app.max_results') < $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); + (config('app.max_results') >= $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; diff --git a/app/Http/Controllers/Api/LocationsController.php b/app/Http/Controllers/Api/LocationsController.php index 6c17c02710..c61dddd620 100644 --- a/app/Http/Controllers/Api/LocationsController.php +++ b/app/Http/Controllers/Api/LocationsController.php @@ -54,7 +54,7 @@ class LocationsController extends Controller $offset = (($locations) && (request('offset') > $locations->count())) ? 0 : request('offset', 0); // Check to make sure the limit is not higher than the max allowed - (config('app.max_results') < $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); + (config('app.max_results') >= $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; $sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at'; diff --git a/app/Http/Controllers/Api/ManufacturersController.php b/app/Http/Controllers/Api/ManufacturersController.php index 4ffbca544d..60da5aadef 100644 --- a/app/Http/Controllers/Api/ManufacturersController.php +++ b/app/Http/Controllers/Api/ManufacturersController.php @@ -42,7 +42,7 @@ class ManufacturersController extends Controller $offset = (($manufacturers) && (request('offset') > $manufacturers->count())) ? 0 : request('offset', 0); // Check to make sure the limit is not higher than the max allowed - (config('app.max_results') < $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); + (config('app.max_results') >= $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; $sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at'; diff --git a/app/Http/Controllers/Api/StatuslabelsController.php b/app/Http/Controllers/Api/StatuslabelsController.php index 4acf2f1a65..261771959d 100644 --- a/app/Http/Controllers/Api/StatuslabelsController.php +++ b/app/Http/Controllers/Api/StatuslabelsController.php @@ -33,7 +33,7 @@ class StatuslabelsController extends Controller $offset = (($statuslabels) && (request('offset') > $statuslabels->count())) ? 0 : request('offset', 0); // Check to make sure the limit is not higher than the max allowed - (config('app.max_results') < $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); + (config('app.max_results') >= $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; $sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at'; diff --git a/app/Http/Controllers/Api/SuppliersController.php b/app/Http/Controllers/Api/SuppliersController.php index b82ed49312..f95070d3d2 100644 --- a/app/Http/Controllers/Api/SuppliersController.php +++ b/app/Http/Controllers/Api/SuppliersController.php @@ -36,7 +36,7 @@ class SuppliersController extends Controller $offset = (($suppliers) && (request('offset') > $suppliers->count())) ? 0 : request('offset', 0); // Check to make sure the limit is not higher than the max allowed - (config('app.max_results') < $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); + (config('app.max_results') >= $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; $sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at'; diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 4710a14686..c8ae878f3f 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -90,7 +90,7 @@ class UsersController extends Controller $offset = (($users) && (request('offset') > $users->count())) ? 0 : request('offset', 0); // Check to make sure the limit is not higher than the max allowed - (config('app.max_results') < $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); + (config('app.max_results') >= $request->input('limit')) ? $limit = $request->input('limit') : $limit = config('app.max_results'); switch ($request->input('sort')) {