From 2d036c64e955aa9596bc240d730f578fd04787db Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 23 May 2019 17:39:50 -0700 Subject: [PATCH] Change ->has() to ->filled() --- .../Controllers/Api/AccessoriesController.php | 10 ++--- .../Api/AssetMaintenancesController.php | 2 +- .../Controllers/Api/AssetModelsController.php | 6 +-- app/Http/Controllers/Api/AssetsController.php | 44 +++++++++---------- .../Controllers/Api/CategoriesController.php | 4 +- .../Controllers/Api/CompaniesController.php | 4 +- .../Controllers/Api/ComponentsController.php | 8 ++-- .../Controllers/Api/ConsumablesController.php | 8 ++-- .../Controllers/Api/DepartmentsController.php | 6 +-- .../Api/DepreciationsController.php | 2 +- app/Http/Controllers/Api/GroupsController.php | 2 +- .../Controllers/Api/LicensesController.php | 26 +++++------ .../Controllers/Api/LocationsController.php | 4 +- .../Api/ManufacturersController.php | 4 +- .../Controllers/Api/ReportsController.php | 10 ++--- .../Api/StatuslabelsController.php | 6 +-- .../Controllers/Api/SuppliersController.php | 4 +- app/Http/Controllers/Api/UsersController.php | 22 +++++----- .../Controllers/AssetCheckinController.php | 4 +- .../Controllers/AssetCheckoutController.php | 4 +- .../Controllers/AssetModelsController.php | 4 +- app/Http/Controllers/AssetsController.php | 12 ++--- app/Http/Controllers/Auth/LoginController.php | 2 +- app/Http/Controllers/BulkAssetsController.php | 40 ++++++++--------- .../Controllers/DepartmentsController.php | 6 +-- app/Http/Controllers/SettingsController.php | 14 +++--- .../Controllers/StatuslabelsController.php | 4 +- app/Http/Controllers/UsersController.php | 32 +++++++------- app/Http/Controllers/ViewAssetsController.php | 2 +- 29 files changed, 148 insertions(+), 148 deletions(-) diff --git a/app/Http/Controllers/Api/AccessoriesController.php b/app/Http/Controllers/Api/AccessoriesController.php index 794c0333cf..467db42f46 100644 --- a/app/Http/Controllers/Api/AccessoriesController.php +++ b/app/Http/Controllers/Api/AccessoriesController.php @@ -26,23 +26,23 @@ class AccessoriesController extends Controller $accessories = Accessory::with('category', 'company', 'manufacturer', 'users', 'location'); - if ($request->has('search')) { + if ($request->filled('search')) { $accessories = $accessories->TextSearch($request->input('search')); } - if ($request->has('company_id')) { + if ($request->filled('company_id')) { $accessories->where('company_id','=',$request->input('company_id')); } - if ($request->has('category_id')) { + if ($request->filled('category_id')) { $accessories->where('category_id','=',$request->input('category_id')); } - if ($request->has('manufacturer_id')) { + if ($request->filled('manufacturer_id')) { $accessories->where('manufacturer_id','=',$request->input('manufacturer_id')); } - if ($request->has('supplier_id')) { + if ($request->filled('supplier_id')) { $accessories->where('supplier_id','=',$request->input('supplier_id')); } diff --git a/app/Http/Controllers/Api/AssetMaintenancesController.php b/app/Http/Controllers/Api/AssetMaintenancesController.php index fd7b401776..e7584ec47a 100644 --- a/app/Http/Controllers/Api/AssetMaintenancesController.php +++ b/app/Http/Controllers/Api/AssetMaintenancesController.php @@ -40,7 +40,7 @@ class AssetMaintenancesController extends Controller $maintenances = $maintenances->TextSearch(e($request->input('search'))); } - if ($request->has('asset_id')) { + if ($request->filled('asset_id')) { $maintenances->where('asset_id', '=', $request->input('asset_id')); } diff --git a/app/Http/Controllers/Api/AssetModelsController.php b/app/Http/Controllers/Api/AssetModelsController.php index de68cd8a9b..ff32180d77 100644 --- a/app/Http/Controllers/Api/AssetModelsController.php +++ b/app/Http/Controllers/Api/AssetModelsController.php @@ -52,11 +52,11 @@ class AssetModelsController extends Controller - if ($request->has('status')) { + if ($request->filled('status')) { $assetmodels->onlyTrashed(); } - if ($request->has('search')) { + if ($request->filled('search')) { $assetmodels->TextSearch($request->input('search')); } @@ -210,7 +210,7 @@ class AssetModelsController extends Controller $settings = \App\Models\Setting::getSettings(); - if ($request->has('search')) { + if ($request->filled('search')) { $assetmodels = $assetmodels->SearchByManufacturerOrCat($request->input('search')); } diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 7e5212c754..0a5d03673c 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -84,7 +84,7 @@ class AssetsController extends Controller $filter = array(); - if ($request->has('filter')) { + if ($request->filled('filter')) { $filter = json_decode($request->input('filter'), true); } @@ -101,7 +101,7 @@ class AssetsController extends Controller // These are used by the API to query against specific ID numbers. // They are also used by the individual searches on detail pages like // locations, etc. - if ($request->has('status_id')) { + if ($request->filled('status_id')) { $assets->where('assets.status_id', '=', $request->input('status_id')); } @@ -109,40 +109,40 @@ class AssetsController extends Controller $assets->where('assets.requestable', '=', '1'); } - if ($request->has('model_id')) { + if ($request->filled('model_id')) { $assets->InModelList([$request->input('model_id')]); } - if ($request->has('category_id')) { + if ($request->filled('category_id')) { $assets->InCategory($request->input('category_id')); } - if ($request->has('location_id')) { + if ($request->filled('location_id')) { $assets->where('assets.location_id', '=', $request->input('location_id')); } - if ($request->has('supplier_id')) { + if ($request->filled('supplier_id')) { $assets->where('assets.supplier_id', '=', $request->input('supplier_id')); } - if (($request->has('assigned_to')) && ($request->has('assigned_type'))) { + if (($request->filled('assigned_to')) && ($request->filled('assigned_type'))) { $assets->where('assets.assigned_to', '=', $request->input('assigned_to')) ->where('assets.assigned_type', '=', $request->input('assigned_type')); } - if ($request->has('company_id')) { + if ($request->filled('company_id')) { $assets->where('assets.company_id', '=', $request->input('company_id')); } - if ($request->has('manufacturer_id')) { + if ($request->filled('manufacturer_id')) { $assets->ByManufacturer($request->input('manufacturer_id')); } - if ($request->has('depreciation_id')) { + if ($request->filled('depreciation_id')) { $assets->ByDepreciationId($request->input('depreciation_id')); } - $request->has('order_number') ? $assets = $assets->where('assets.order_number', '=', e($request->get('order_number'))) : ''; + $request->filled('order_number') ? $assets = $assets->where('assets.order_number', '=', e($request->get('order_number'))) : ''; $offset = (($assets) && (request('offset') > $assets->count())) ? 0 : request('offset', 0); $limit = $request->input('limit', 50); @@ -216,7 +216,7 @@ class AssetsController extends Controller break; default: - if ((!$request->has('status_id')) && ($settings->show_archived_in_list!='1')) { + if ((!$request->filled('status_id')) && ($settings->show_archived_in_list!='1')) { // terrible workaround for complex-query Laravel bug in fulltext $assets->join('status_labels AS status_alias',function ($join) { $join->on('status_alias.id', "=", "assets.status_id") @@ -235,7 +235,7 @@ class AssetsController extends Controller if ((!is_null($filter)) && (count($filter)) > 0) { $assets->ByFilter($filter); - } elseif ($request->has('search')) { + } elseif ($request->filled('search')) { $assets->TextSearch($request->input('search')); } @@ -371,11 +371,11 @@ class AssetsController extends Controller 'assets.status_id' ])->with('model', 'assetstatus', 'assignedTo')->NotArchived(),'company_id', 'assets'); - if ($request->has('assetStatusType') && $request->input('assetStatusType') === 'RTD') { + if ($request->filled('assetStatusType') && $request->input('assetStatusType') === 'RTD') { $assets = $assets->RTD(); } - if ($request->has('search')) { + if ($request->filled('search')) { $assets = $assets->AssignedSearch($request->input('search')); } @@ -493,11 +493,11 @@ class AssetsController extends Controller $asset->fill($request->all()); - ($request->has('model_id')) ? + ($request->filled('model_id')) ? $asset->model()->associate(AssetModel::find($request->get('model_id'))) : null; - ($request->has('company_id')) ? + ($request->filled('company_id')) ? $asset->company_id = Company::getIdForCurrentUser($request->get('company_id')) : null; - ($request->has('rtd_location_id')) ? + ($request->filled('rtd_location_id')) ? $asset->location_id = $request->get('rtd_location_id') : null; // Update custom fields @@ -518,11 +518,11 @@ class AssetsController extends Controller if ($asset->save()) { - if (($request->has('assigned_user')) && ($target = User::find($request->get('assigned_user')))) { + if (($request->filled('assigned_user')) && ($target = User::find($request->get('assigned_user')))) { $location = $target->location_id; - } elseif (($request->has('assigned_asset')) && ($target = Asset::find($request->get('assigned_asset')))) { + } elseif (($request->filled('assigned_asset')) && ($target = Asset::find($request->get('assigned_asset')))) { $location = $target->location_id; - } elseif (($request->has('assigned_location')) && ($target = Location::find($request->get('assigned_location')))) { + } elseif (($request->filled('assigned_location')) && ($target = Location::find($request->get('assigned_location')))) { $location = $target->id; } @@ -677,7 +677,7 @@ class AssetsController extends Controller $asset->name = Input::get('name'); $asset->location_id = $asset->rtd_location_id; - if ($request->has('location_id')) { + if ($request->filled('location_id')) { $asset->location_id = $request->input('location_id'); } diff --git a/app/Http/Controllers/Api/CategoriesController.php b/app/Http/Controllers/Api/CategoriesController.php index c210c4b942..a67569387c 100644 --- a/app/Http/Controllers/Api/CategoriesController.php +++ b/app/Http/Controllers/Api/CategoriesController.php @@ -26,7 +26,7 @@ class CategoriesController extends Controller $categories = Category::select(['id', 'created_at', 'updated_at', 'name','category_type','use_default_eula','eula_text', 'require_acceptance','checkin_email','image']) ->withCount('assets as assets_count', 'accessories as accessories_count', 'consumables as consumables_count', 'components as components_count','licenses as licenses_count'); - if ($request->has('search')) { + if ($request->filled('search')) { $categories = $categories->TextSearch($request->input('search')); } @@ -148,7 +148,7 @@ class CategoriesController extends Controller 'image', ]); - if ($request->has('search')) { + if ($request->filled('search')) { $categories = $categories->where('name', 'LIKE', '%'.$request->get('search').'%'); } diff --git a/app/Http/Controllers/Api/CompaniesController.php b/app/Http/Controllers/Api/CompaniesController.php index 40735fd093..684045d71d 100644 --- a/app/Http/Controllers/Api/CompaniesController.php +++ b/app/Http/Controllers/Api/CompaniesController.php @@ -37,7 +37,7 @@ class CompaniesController extends Controller $companies = Company::withCount('assets as assets_count','licenses as licenses_count','accessories as accessories_count','consumables as consumables_count','components as components_count','users as users_count'); - if ($request->has('search')) { + if ($request->filled('search')) { $companies->TextSearch($request->input('search')); } @@ -168,7 +168,7 @@ class CompaniesController extends Controller 'companies.image', ]); - if ($request->has('search')) { + if ($request->filled('search')) { $companies = $companies->where('companies.name', 'LIKE', '%'.$request->get('search').'%'); } diff --git a/app/Http/Controllers/Api/ComponentsController.php b/app/Http/Controllers/Api/ComponentsController.php index 8f1accf64b..e077a6ea48 100644 --- a/app/Http/Controllers/Api/ComponentsController.php +++ b/app/Http/Controllers/Api/ComponentsController.php @@ -27,19 +27,19 @@ class ComponentsController extends Controller $components = Company::scopeCompanyables(Component::select('components.*') ->with('company', 'location', 'category')); - if ($request->has('search')) { + if ($request->filled('search')) { $components = $components->TextSearch($request->input('search')); } - if ($request->has('company_id')) { + if ($request->filled('company_id')) { $components->where('company_id','=',$request->input('company_id')); } - if ($request->has('category_id')) { + if ($request->filled('category_id')) { $components->where('category_id','=',$request->input('category_id')); } - if ($request->has('location_id')) { + if ($request->filled('location_id')) { $components->where('location_id','=',$request->input('location_id')); } diff --git a/app/Http/Controllers/Api/ConsumablesController.php b/app/Http/Controllers/Api/ConsumablesController.php index d609c35a9c..8a258dbea1 100644 --- a/app/Http/Controllers/Api/ConsumablesController.php +++ b/app/Http/Controllers/Api/ConsumablesController.php @@ -27,19 +27,19 @@ class ConsumablesController extends Controller ->with('company', 'location', 'category', 'users', 'manufacturer') ); - if ($request->has('search')) { + if ($request->filled('search')) { $consumables = $consumables->TextSearch(e($request->input('search'))); } - if ($request->has('company_id')) { + if ($request->filled('company_id')) { $consumables->where('company_id','=',$request->input('company_id')); } - if ($request->has('category_id')) { + if ($request->filled('category_id')) { $consumables->where('category_id','=',$request->input('category_id')); } - if ($request->has('manufacturer_id')) { + if ($request->filled('manufacturer_id')) { $consumables->where('manufacturer_id','=',$request->input('manufacturer_id')); } diff --git a/app/Http/Controllers/Api/DepartmentsController.php b/app/Http/Controllers/Api/DepartmentsController.php index 44d0273ef0..0b933e1417 100644 --- a/app/Http/Controllers/Api/DepartmentsController.php +++ b/app/Http/Controllers/Api/DepartmentsController.php @@ -35,7 +35,7 @@ class DepartmentsController extends Controller 'departments.image' ])->with('users')->with('location')->with('manager')->with('company')->withCount('users as users_count'); - if ($request->has('search')) { + if ($request->filled('search')) { $departments = $departments->TextSearch($request->input('search')); } @@ -76,7 +76,7 @@ class DepartmentsController extends Controller $department = new Department; $department->fill($request->all()); $department->user_id = Auth::user()->id; - $department->manager_id = ($request->has('manager_id' ) ? $request->input('manager_id') : null); + $department->manager_id = ($request->filled('manager_id' ) ? $request->input('manager_id') : null); if ($department->save()) { return response()->json(Helper::formatStandardApiResponse('success', $department, trans('admin/departments/message.create.success'))); @@ -142,7 +142,7 @@ class DepartmentsController extends Controller 'image', ]); - if ($request->has('search')) { + if ($request->filled('search')) { $departments = $departments->where('name', 'LIKE', '%'.$request->get('search').'%'); } diff --git a/app/Http/Controllers/Api/DepreciationsController.php b/app/Http/Controllers/Api/DepreciationsController.php index 47e2c8de53..119b233db5 100644 --- a/app/Http/Controllers/Api/DepreciationsController.php +++ b/app/Http/Controllers/Api/DepreciationsController.php @@ -24,7 +24,7 @@ class DepreciationsController extends Controller $depreciations = Depreciation::select('id','name','months','user_id','created_at','updated_at'); - if ($request->has('search')) { + if ($request->filled('search')) { $depreciations = $depreciations->TextSearch($request->input('search')); } diff --git a/app/Http/Controllers/Api/GroupsController.php b/app/Http/Controllers/Api/GroupsController.php index 439dde4a61..e1296fc7c3 100644 --- a/app/Http/Controllers/Api/GroupsController.php +++ b/app/Http/Controllers/Api/GroupsController.php @@ -24,7 +24,7 @@ class GroupsController extends Controller $groups = Group::select('id','name','permissions','created_at','updated_at')->withCount('users as users_count'); - if ($request->has('search')) { + if ($request->filled('search')) { $groups = $groups->TextSearch($request->input('search')); } diff --git a/app/Http/Controllers/Api/LicensesController.php b/app/Http/Controllers/Api/LicensesController.php index 95760e6e89..3178960807 100644 --- a/app/Http/Controllers/Api/LicensesController.php +++ b/app/Http/Controllers/Api/LicensesController.php @@ -28,56 +28,56 @@ class LicensesController extends Controller $licenses = Company::scopeCompanyables(License::with('company', 'manufacturer', 'freeSeats', 'supplier','category')->withCount('freeSeats as freeSeats_count')); - if ($request->has('company_id')) { + if ($request->filled('company_id')) { $licenses->where('company_id','=',$request->input('company_id')); } - if ($request->has('name')) { + if ($request->filled('name')) { $licenses->where('licenses.name','=',$request->input('name')); } - if ($request->has('product_key')) { + if ($request->filled('product_key')) { $licenses->where('licenses.serial','=',$request->input('product_key')); } - if ($request->has('order_number')) { + if ($request->filled('order_number')) { $licenses->where('order_number','=',$request->input('order_number')); } - if ($request->has('purchase_order')) { + if ($request->filled('purchase_order')) { $licenses->where('purchase_order','=',$request->input('purchase_order')); } - if ($request->has('license_name')) { + if ($request->filled('license_name')) { $licenses->where('license_name','=',$request->input('license_name')); } - if ($request->has('license_email')) { + if ($request->filled('license_email')) { $licenses->where('license_email','=',$request->input('license_email')); } - if ($request->has('manufacturer_id')) { + if ($request->filled('manufacturer_id')) { $licenses->where('manufacturer_id','=',$request->input('manufacturer_id')); } - if ($request->has('supplier_id')) { + if ($request->filled('supplier_id')) { $licenses->where('supplier_id','=',$request->input('supplier_id')); } - if ($request->has('category_id')) { + if ($request->filled('category_id')) { $licenses->where('category_id','=',$request->input('category_id')); } - if ($request->has('depreciation_id')) { + if ($request->filled('depreciation_id')) { $licenses->where('depreciation_id','=',$request->input('depreciation_id')); } - if ($request->has('supplier_id')) { + if ($request->filled('supplier_id')) { $licenses->where('supplier_id','=',$request->input('supplier_id')); } - if ($request->has('search')) { + if ($request->filled('search')) { $licenses = $licenses->TextSearch($request->input('search')); } diff --git a/app/Http/Controllers/Api/LocationsController.php b/app/Http/Controllers/Api/LocationsController.php index 4b54068228..0ebc4c39e0 100644 --- a/app/Http/Controllers/Api/LocationsController.php +++ b/app/Http/Controllers/Api/LocationsController.php @@ -45,7 +45,7 @@ class LocationsController extends Controller ->withCount('assets as assets_count') ->withCount('users as users_count'); - if ($request->has('search')) { + if ($request->filled('search')) { $locations = $locations->TextSearch($request->input('search')); } @@ -192,7 +192,7 @@ class LocationsController extends Controller 'locations.image', ]); - if ($request->has('search')) { + if ($request->filled('search')) { $locations = $locations->where('locations.name', 'LIKE', '%'.$request->get('search').'%'); } diff --git a/app/Http/Controllers/Api/ManufacturersController.php b/app/Http/Controllers/Api/ManufacturersController.php index d7535d3bb1..5f1289cdeb 100644 --- a/app/Http/Controllers/Api/ManufacturersController.php +++ b/app/Http/Controllers/Api/ManufacturersController.php @@ -32,7 +32,7 @@ class ManufacturersController extends Controller $manufacturers->onlyTrashed(); } - if ($request->has('search')) { + if ($request->filled('search')) { $manufacturers = $manufacturers->TextSearch($request->input('search')); } @@ -145,7 +145,7 @@ class ManufacturersController extends Controller 'image', ]); - if ($request->has('search')) { + if ($request->filled('search')) { $manufacturers = $manufacturers->where('name', 'LIKE', '%'.$request->get('search').'%'); } diff --git a/app/Http/Controllers/Api/ReportsController.php b/app/Http/Controllers/Api/ReportsController.php index 277aa8b765..e1b6ddd813 100644 --- a/app/Http/Controllers/Api/ReportsController.php +++ b/app/Http/Controllers/Api/ReportsController.php @@ -22,25 +22,25 @@ class ReportsController extends Controller $actionlogs = Actionlog::with('item', 'user', 'target','location'); - if ($request->has('search')) { + if ($request->filled('search')) { $actionlogs = $actionlogs->TextSearch(e($request->input('search'))); } - if (($request->has('target_type')) && ($request->has('target_id'))) { + if (($request->filled('target_type')) && ($request->filled('target_id'))) { $actionlogs = $actionlogs->where('target_id','=',$request->input('target_id')) ->where('target_type','=',"App\\Models\\".ucwords($request->input('target_type'))); } - if (($request->has('item_type')) && ($request->has('item_id'))) { + if (($request->filled('item_type')) && ($request->filled('item_id'))) { $actionlogs = $actionlogs->where('item_id','=',$request->input('item_id')) ->where('item_type','=',"App\\Models\\".ucwords($request->input('item_type'))); } - if ($request->has('action_type')) { + if ($request->filled('action_type')) { $actionlogs = $actionlogs->where('action_type','=',$request->input('action_type'))->orderBy('created_at', 'desc'); } - if ($request->has('uploads')) { + if ($request->filled('uploads')) { $actionlogs = $actionlogs->whereNotNull('filename')->orderBy('created_at', 'desc'); } diff --git a/app/Http/Controllers/Api/StatuslabelsController.php b/app/Http/Controllers/Api/StatuslabelsController.php index 0ba0d82c63..32405c9a34 100644 --- a/app/Http/Controllers/Api/StatuslabelsController.php +++ b/app/Http/Controllers/Api/StatuslabelsController.php @@ -26,7 +26,7 @@ class StatuslabelsController extends Controller $statuslabels = Statuslabel::withCount('assets as assets_count'); - if ($request->has('search')) { + if ($request->filled('search')) { $statuslabels = $statuslabels->TextSearch($request->input('search')); } @@ -55,7 +55,7 @@ class StatuslabelsController extends Controller $this->authorize('create', Statuslabel::class); $request->except('deployable', 'pending','archived'); - if (!$request->has('type')) { + if (!$request->filled('type')) { return response()->json(Helper::formatStandardApiResponse('error', null, ["type" => ["Status label type is required."]]),500); } @@ -106,7 +106,7 @@ class StatuslabelsController extends Controller $request->except('deployable', 'pending','archived'); - if (!$request->has('type')) { + if (!$request->filled('type')) { return response()->json(Helper::formatStandardApiResponse('error', null, 'Status label type is required.')); } diff --git a/app/Http/Controllers/Api/SuppliersController.php b/app/Http/Controllers/Api/SuppliersController.php index b725c7d443..13b9a926ac 100644 --- a/app/Http/Controllers/Api/SuppliersController.php +++ b/app/Http/Controllers/Api/SuppliersController.php @@ -29,7 +29,7 @@ class SuppliersController extends Controller )->withCount('assets as assets_count')->withCount('licenses as licenses_count')->withCount('accessories as accessories_count'); - if ($request->has('search')) { + if ($request->filled('search')) { $suppliers = $suppliers->TextSearch($request->input('search')); } @@ -153,7 +153,7 @@ class SuppliersController extends Controller 'image', ]); - if ($request->has('search')) { + if ($request->filled('search')) { $suppliers = $suppliers->where('suppliers.name', 'LIKE', '%'.$request->get('search').'%'); } diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 2b1196b093..0e6ade1631 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -62,27 +62,27 @@ class UsersController extends Controller $users = Company::scopeCompanyables($users); - if (($request->has('deleted')) && ($request->input('deleted')=='true')) { + if (($request->filled('deleted')) && ($request->input('deleted')=='true')) { $users = $users->GetDeleted(); } - if ($request->has('company_id')) { + if ($request->filled('company_id')) { $users = $users->where('users.company_id', '=', $request->input('company_id')); } - if ($request->has('location_id')) { + if ($request->filled('location_id')) { $users = $users->where('users.location_id', '=', $request->input('location_id')); } - if ($request->has('group_id')) { + if ($request->filled('group_id')) { $users = $users->ByGroup($request->get('group_id')); } - if ($request->has('department_id')) { + if ($request->filled('department_id')) { $users = $users->where('users.department_id','=',$request->input('department_id')); } - if ($request->has('search')) { + if ($request->filled('search')) { $users = $users->TextSearch($request->input('search')); } @@ -148,7 +148,7 @@ class UsersController extends Controller $users = Company::scopeCompanyables($users); - if ($request->has('search')) { + if ($request->filled('search')) { $users = $users->SimpleNameSearch($request->get('search')) ->orWhere('username', 'LIKE', '%'.$request->get('search').'%') ->orWhere('employee_num', 'LIKE', '%'.$request->get('search').'%'); @@ -201,7 +201,7 @@ class UsersController extends Controller $user->password = bcrypt($request->get('password', $tmp_pass)); if ($user->save()) { - if ($request->has('groups')) { + if ($request->filled('groups')) { $user->groups()->sync($request->input('groups')); } else { $user->groups()->sync(array()); @@ -247,7 +247,7 @@ class UsersController extends Controller return response()->json(Helper::formatStandardApiResponse('error', null, 'You cannot be your own manager')); } - if ($request->has('password')) { + if ($request->filled('password')) { $user->password = bcrypt($request->input('password')); } @@ -257,7 +257,7 @@ class UsersController extends Controller if ($user->save()) { - if ($request->has('groups')) { + if ($request->filled('groups')) { $user->groups()->sync($request->input('groups')); } else { $user->groups()->sync(array()); @@ -340,7 +340,7 @@ class UsersController extends Controller $this->authorize('update', User::class); - if ($request->has('id')) { + if ($request->filled('id')) { try { $user = User::find($request->get('id')); $user->two_factor_secret = null; diff --git a/app/Http/Controllers/AssetCheckinController.php b/app/Http/Controllers/AssetCheckinController.php index e03ea8b529..30cdb24126 100644 --- a/app/Http/Controllers/AssetCheckinController.php +++ b/app/Http/Controllers/AssetCheckinController.php @@ -67,13 +67,13 @@ class AssetCheckinController extends Controller $asset->accepted = null; $asset->name = e($request->get('name')); - if ($request->has('status_id')) { + if ($request->filled('status_id')) { $asset->status_id = e($request->get('status_id')); } $asset->location_id = $asset->rtd_location_id; - if ($request->has('location_id')) { + if ($request->filled('location_id')) { $asset->location_id = e($request->get('location_id')); } diff --git a/app/Http/Controllers/AssetCheckoutController.php b/app/Http/Controllers/AssetCheckoutController.php index 7220c35fa5..0dd499482f 100644 --- a/app/Http/Controllers/AssetCheckoutController.php +++ b/app/Http/Controllers/AssetCheckoutController.php @@ -71,12 +71,12 @@ class AssetCheckoutController extends Controller $asset = $this->updateAssetLocation($asset, $target); $checkout_at = date("Y-m-d H:i:s"); - if (($request->has('checkout_at')) && ($request->get('checkout_at')!= date("Y-m-d"))) { + if (($request->filled('checkout_at')) && ($request->get('checkout_at')!= date("Y-m-d"))) { $checkout_at = $request->get('checkout_at'); } $expected_checkin = ''; - if ($request->has('expected_checkin')) { + if ($request->filled('expected_checkin')) { $expected_checkin = $request->get('expected_checkin'); } diff --git a/app/Http/Controllers/AssetModelsController.php b/app/Http/Controllers/AssetModelsController.php index 0999327474..0c548bf0a0 100755 --- a/app/Http/Controllers/AssetModelsController.php +++ b/app/Http/Controllers/AssetModelsController.php @@ -420,10 +420,10 @@ class AssetModelsController extends Controller $update_array = array(); - if (($request->has('manufacturer_id') && ($request->input('manufacturer_id')!='NC'))) { + if (($request->filled('manufacturer_id') && ($request->input('manufacturer_id')!='NC'))) { $update_array['manufacturer_id'] = $request->input('manufacturer_id'); } - if (($request->has('category_id') && ($request->input('category_id')!='NC'))) { + if (($request->filled('category_id') && ($request->input('category_id')!='NC'))) { $update_array['category_id'] = $request->input('category_id'); } if ($request->input('fieldset_id')!='NC') { diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.php index 71b54cc1b6..924d16655f 100755 --- a/app/Http/Controllers/AssetsController.php +++ b/app/Http/Controllers/AssetsController.php @@ -71,7 +71,7 @@ class AssetsController extends Controller public function index(Request $request) { $this->authorize('index', Asset::class); - if ($request->has('company_id')) { + if ($request->filled('company_id')) { $company = Company::find($request->input('company_id')); } else { $company = null; @@ -96,7 +96,7 @@ class AssetsController extends Controller ->with('item', new Asset) ->with('statuslabel_types', Helper::statusTypeList()); - if ($request->has('model_id')) { + if ($request->filled('model_id')) { $selected_model = AssetModel::find($request->input('model_id')); $view->with('selected_model', $selected_model); } @@ -143,7 +143,7 @@ class AssetsController extends Controller } // Create the image (if one was chosen.) - if ($request->has('image')) { + if ($request->filled('image')) { $image = $request->input('image'); // After modification, the image is prefixed by mime info like the following: @@ -313,7 +313,7 @@ class AssetsController extends Controller $asset->supplier_id = $request->input('supplier_id', null); // If the box isn't checked, it's not in the request at all. - $asset->requestable = $request->has('requestable'); + $asset->requestable = $request->filled('requestable'); $asset->rtd_location_id = $request->input('rtd_location_id', null); if ($asset->assigned_to=='') { @@ -321,7 +321,7 @@ class AssetsController extends Controller } - if ($request->has('image_delete')) { + if ($request->filled('image_delete')) { try { unlink(public_path().'/uploads/assets/'.$asset->image); $asset->image = ''; @@ -343,7 +343,7 @@ class AssetsController extends Controller $asset->physical = '1'; // Update the image - if ($request->has('image')) { + if ($request->filled('image')) { $image = $request->input('image'); // See postCreate for more explaination of the following. $header = explode(';', $image, 2)[0]; diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index e13376c9f1..78207e8f5e 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -275,7 +275,7 @@ class LoginController extends Controller return redirect()->route('login')->with('error', trans('auth/general.login_prompt')); } - if (!$request->has('two_factor_secret')) { + if (!$request->filled('two_factor_secret')) { return redirect()->route('two-factor')->with('error', trans('auth/message.two_factor.code_required')); } diff --git a/app/Http/Controllers/BulkAssetsController.php b/app/Http/Controllers/BulkAssetsController.php index cec9adf7f8..38a2009470 100644 --- a/app/Http/Controllers/BulkAssetsController.php +++ b/app/Http/Controllers/BulkAssetsController.php @@ -26,13 +26,13 @@ class BulkAssetsController extends Controller { $this->authorize('update', Asset::class); - if (!$request->has('ids')) { + if (!$request->filled('ids')) { return redirect()->back()->with('error', 'No assets selected'); } $asset_ids = array_keys($request->input('ids')); - if ($request->has('bulk_actions')) { + if ($request->filled('bulk_actions')) { switch($request->input('bulk_actions')) { case 'labels': return view('hardware/labels') @@ -68,22 +68,22 @@ class BulkAssetsController extends Controller \Log::debug($request->input('ids')); - if(!$request->has('ids') || count($request->input('ids')) <= 0) { + if(!$request->filled('ids') || count($request->input('ids')) <= 0) { return redirect()->route("hardware.index")->with('warning', trans('No assets selected, so nothing was updated.')); } $assets = array_keys($request->input('ids')); - if (($request->has('purchase_date')) - || ($request->has('purchase_cost')) - || ($request->has('supplier_id')) - || ($request->has('order_number')) - || ($request->has('warranty_months')) - || ($request->has('rtd_location_id')) - || ($request->has('requestable')) - || ($request->has('company_id')) - || ($request->has('status_id')) - || ($request->has('model_id')) + if (($request->filled('purchase_date')) + || ($request->filled('purchase_cost')) + || ($request->filled('supplier_id')) + || ($request->filled('order_number')) + || ($request->filled('warranty_months')) + || ($request->filled('rtd_location_id')) + || ($request->filled('requestable')) + || ($request->filled('company_id')) + || ($request->filled('status_id')) + || ($request->filled('model_id')) ) { foreach ($assets as $assetId) { $this->update_array = []; @@ -96,20 +96,20 @@ class BulkAssetsController extends Controller ->conditionallyAddItem('supplier_id') ->conditionallyAddItem('warranty_months'); - if ($request->has('purchase_cost')) { + if ($request->filled('purchase_cost')) { $this->update_array['purchase_cost'] = Helper::ParseFloat($request->input('purchase_cost')); } - if ($request->has('company_id')) { + if ($request->filled('company_id')) { $this->update_array['company_id'] = $request->input('company_id'); if ($request->input('company_id')=="clear") { $this->update_array['company_id'] = null; } } - if ($request->has('rtd_location_id')) { + if ($request->filled('rtd_location_id')) { $this->update_array['rtd_location_id'] = $request->input('rtd_location_id'); - if (($request->has('update_real_loc')) && (($request->input('update_real_loc')) == '1')) { + if (($request->filled('update_real_loc')) && (($request->input('update_real_loc')) == '1')) { $this->update_array['location_id'] = $request->input('rtd_location_id'); } } @@ -155,7 +155,7 @@ class BulkAssetsController extends Controller { $this->authorize('delete', Asset::class); - if ($request->has('ids')) { + if ($request->filled('ids')) { $assets = Asset::find($request->get('ids')); foreach ($assets as $asset) { $update_array['deleted_at'] = date('Y-m-d H:i:s'); @@ -206,13 +206,13 @@ class BulkAssetsController extends Controller } } $checkout_at = date("Y-m-d H:i:s"); - if (($request->has('checkout_at')) && ($request->get('checkout_at')!= date("Y-m-d"))) { + if (($request->filled('checkout_at')) && ($request->get('checkout_at')!= date("Y-m-d"))) { $checkout_at = e($request->get('checkout_at')); } $expected_checkin = ''; - if ($request->has('expected_checkin')) { + if ($request->filled('expected_checkin')) { $expected_checkin = e($request->get('expected_checkin')); } diff --git a/app/Http/Controllers/DepartmentsController.php b/app/Http/Controllers/DepartmentsController.php index 42eeff89d7..2717c717e6 100644 --- a/app/Http/Controllers/DepartmentsController.php +++ b/app/Http/Controllers/DepartmentsController.php @@ -30,7 +30,7 @@ class DepartmentsController extends Controller { $this->authorize('index', Department::class); $company = null; - if ($request->has('company_id')) { + if ($request->filled('company_id')) { $company = Company::find($request->input('company_id')); } return view('departments/index')->with('company', $company); @@ -51,7 +51,7 @@ class DepartmentsController extends Controller $department = new Department; $department->fill($request->all()); $department->user_id = Auth::user()->id; - $department->manager_id = ($request->has('manager_id' ) ? $request->input('manager_id') : null); + $department->manager_id = ($request->filled('manager_id' ) ? $request->input('manager_id') : null); if ($request->file('image')) { $image = $request->file('image'); @@ -162,7 +162,7 @@ class DepartmentsController extends Controller $this->authorize('update', $department); $department->fill($request->all()); - $department->manager_id = ($request->has('manager_id' ) ? $request->input('manager_id') : null); + $department->manager_id = ($request->filled('manager_id' ) ? $request->input('manager_id') : null); $old_image = $department->image; diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index c44f200344..f7c46a1248 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -326,7 +326,7 @@ class SettingsController extends Controller $setting->modellist_displays = ''; - if (($request->has('show_in_model_list')) && (count($request->input('show_in_model_list')) > 0)) + if (($request->filled('show_in_model_list')) && (count($request->input('show_in_model_list')) > 0)) { $setting->modellist_displays = implode(',', $request->input('show_in_model_list')); } @@ -495,7 +495,7 @@ class SettingsController extends Controller $setting->pwd_secure_complexity = ''; - if ($request->has('pwd_secure_complexity')) { + if ($request->filled('pwd_secure_complexity')) { $setting->pwd_secure_complexity = implode('|', $request->input('pwd_secure_complexity')); } @@ -794,31 +794,31 @@ class SettingsController extends Controller - if ($request->has('labels_display_name')) { + if ($request->filled('labels_display_name')) { $setting->labels_display_name = 1; } else { $setting->labels_display_name = 0; } - if ($request->has('labels_display_serial')) { + if ($request->filled('labels_display_serial')) { $setting->labels_display_serial = 1; } else { $setting->labels_display_serial = 0; } - if ($request->has('labels_display_tag')) { + if ($request->filled('labels_display_tag')) { $setting->labels_display_tag = 1; } else { $setting->labels_display_tag = 0; } - if ($request->has('labels_display_tag')) { + if ($request->filled('labels_display_tag')) { $setting->labels_display_tag = 1; } else { $setting->labels_display_tag = 0; } - if ($request->has('labels_display_model')) { + if ($request->filled('labels_display_model')) { $setting->labels_display_model = 1; } else { $setting->labels_display_model = 0; diff --git a/app/Http/Controllers/StatuslabelsController.php b/app/Http/Controllers/StatuslabelsController.php index cb096ea35d..b1b743e772 100755 --- a/app/Http/Controllers/StatuslabelsController.php +++ b/app/Http/Controllers/StatuslabelsController.php @@ -78,7 +78,7 @@ class StatuslabelsController extends Controller // create a new model instance $statusLabel = new Statuslabel(); - if (!$request->has('statuslabel_types')) { + if (!$request->filled('statuslabel_types')) { return redirect()->back()->withInput()->withErrors(['statuslabel_types' => trans('validation.statuslabel_type')]); } @@ -141,7 +141,7 @@ class StatuslabelsController extends Controller return redirect()->route('statuslabels.index')->with('error', trans('admin/statuslabels/message.does_not_exist')); } - if (!$request->has('statuslabel_types')) { + if (!$request->filled('statuslabel_types')) { return redirect()->back()->withInput()->withErrors(['statuslabel_types' => trans('validation.statuslabel_type')]); } diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php index d80c1e5dff..2e4223c63b 100755 --- a/app/Http/Controllers/UsersController.php +++ b/app/Http/Controllers/UsersController.php @@ -107,7 +107,7 @@ class UsersController extends Controller //Username, email, and password need to be handled specially because the need to respect config values on an edit. $user->email = $data['email'] = e($request->input('email')); $user->username = $data['username'] = e($request->input('username')); - if ($request->has('password')) { + if ($request->filled('password')) { $user->password = bcrypt($request->input('password')); $data['password'] = $request->input('password'); } @@ -139,13 +139,13 @@ class UsersController extends Controller if ($user->save()) { - if ($request->has('groups')) { + if ($request->filled('groups')) { $user->groups()->sync($request->input('groups')); } else { $user->groups()->sync(array()); } - if (($request->input('email_user') == 1) && ($request->has('email'))) { + if (($request->input('email_user') == 1) && ($request->filled('email'))) { // Send the credentials through email $data = array(); $data['email'] = e($request->input('email')); @@ -263,7 +263,7 @@ class UsersController extends Controller } - if ($request->has('username')) { + if ($request->filled('username')) { $user->username = $request->input('username'); } $user->email = $request->input('email'); @@ -297,7 +297,7 @@ class UsersController extends Controller ->where('assigned_to', $user->id)->update(['location_id' => $request->input('location_id', null)]); // Do we want to update the user password? - if ($request->has('password')) { + if ($request->filled('password')) { $user->password = bcrypt($request->input('password')); } @@ -390,7 +390,7 @@ class UsersController extends Controller { $this->authorize('update', User::class); - if (($request->has('ids')) && (count($request->input('ids')) > 0)) { + if (($request->filled('ids')) && (count($request->input('ids')) > 0)) { $statuslabel_list = Helper::statusLabelList(); $user_raw_array = array_keys(Input::get('ids')); $users = User::whereIn('id', $user_raw_array)->with('groups', 'assets', 'licenses', 'accessories')->get(); @@ -416,28 +416,28 @@ class UsersController extends Controller { $this->authorize('update', User::class); - if (($request->has('ids')) && (count($request->input('ids')) > 0)) { + if (($request->filled('ids')) && (count($request->input('ids')) > 0)) { $user_raw_array = $request->input('ids'); $update_array = array(); $manager_conflict = false; $users = User::whereIn('id', $user_raw_array)->where('id', '!=', Auth::user()->id)->get(); - if ($request->has('location_id')) { + if ($request->filled('location_id')) { $update_array['location_id'] = $request->input('location_id'); } - if ($request->has('department_id')) { + if ($request->filled('department_id')) { $update_array['department_id'] = $request->input('department_id'); } - if ($request->has('company_id')) { + if ($request->filled('company_id')) { $update_array['company_id'] = $request->input('company_id'); } - if ($request->has('locale')) { + if ($request->filled('locale')) { $update_array['locale'] = $request->input('locale'); } - if ($request->has('manager_id')) { + if ($request->filled('manager_id')) { // Do not allow a manager update if the selected manager is one of the users being // edited. @@ -448,7 +448,7 @@ class UsersController extends Controller } } - if ($request->has('activated')) { + if ($request->filled('activated')) { $update_array['activated'] = $request->input('activated'); } @@ -458,7 +458,7 @@ class UsersController extends Controller } // Only sync groups if groups were selected - if ($request->has('groups')) { + if ($request->filled('groups')) { foreach ($users as $user) { $user->groups()->sync($request->input('groups')); } @@ -490,9 +490,9 @@ class UsersController extends Controller { $this->authorize('update', User::class); - if ((!$request->has('ids')) || (count($request->input('ids')) == 0)) { + if ((!$request->filled('ids')) || (count($request->input('ids')) == 0)) { return redirect()->back()->with('error', 'No users selected'); - } elseif ((!$request->has('status_id')) || ($request->input('status_id')=='')) { + } elseif ((!$request->filled('status_id')) || ($request->input('status_id')=='')) { return redirect()->route('users.index')->with('error', 'No status selected'); } else { diff --git a/app/Http/Controllers/ViewAssetsController.php b/app/Http/Controllers/ViewAssetsController.php index 5bf48bb8b0..0f72f10d2b 100755 --- a/app/Http/Controllers/ViewAssetsController.php +++ b/app/Http/Controllers/ViewAssetsController.php @@ -269,7 +269,7 @@ class ViewAssetsController extends Controller return redirect()->to('account/view-assets')->with('error', trans('admin/users/message.error.incorrect_user_accepted')); } - if ($request->has('signature_output')) { + if ($request->filled('signature_output')) { $path = config('app.private_uploads').'/signatures'; $sig_filename = "siglog-".$findlog->id.'-'.date('Y-m-d-his').".png"; $data_uri = e($request->get('signature_output'));