Change $request->has to $request->filled unilaterally

This commit is contained in:
snipe 2018-07-24 22:51:31 -07:00
parent 0714ac4248
commit 86c1f11bec
32 changed files with 234 additions and 234 deletions

View file

@ -26,23 +26,23 @@ class AccessoriesController extends Controller
$accessories = Accessory::with('category', 'company', 'manufacturer', 'users', 'location'); $accessories = Accessory::with('category', 'company', 'manufacturer', 'users', 'location');
if ($request->has('search')) { if ($request->filled('search')) {
$accessories = $accessories->TextSearch($request->input('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')); $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')); $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')); $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')); $accessories->where('supplier_id','=',$request->input('supplier_id'));
} }

View file

@ -40,7 +40,7 @@ class AssetMaintenancesController extends Controller
$maintenances = $maintenances->TextSearch(e($request->input('search'))); $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')); $maintenances->where('asset_id', '=', $request->input('asset_id'));
} }

View file

@ -52,11 +52,11 @@ class AssetModelsController extends Controller
if ($request->has('status')) { if ($request->filled('status')) {
$assetmodels->onlyTrashed(); $assetmodels->onlyTrashed();
} }
if ($request->has('search')) { if ($request->filled('search')) {
$assetmodels->TextSearch($request->input('search')); $assetmodels->TextSearch($request->input('search'));
} }
@ -210,7 +210,7 @@ class AssetModelsController extends Controller
$settings = \App\Models\Setting::getSettings(); $settings = \App\Models\Setting::getSettings();
if ($request->has('search')) { if ($request->filled('search')) {
$assetmodels = $assetmodels->SearchByManufacturerOrCat($request->input('search')); $assetmodels = $assetmodels->SearchByManufacturerOrCat($request->input('search'));
} }

View file

@ -84,7 +84,7 @@ class AssetsController extends Controller
$filter = array(); $filter = array();
if ($request->has('filter')) { if ($request->filled('filter')) {
$filter = json_decode($request->input('filter'), true); $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. // These are used by the API to query against specific ID numbers.
// They are also used by the individual searches on detail pages like // They are also used by the individual searches on detail pages like
// locations, etc. // locations, etc.
if ($request->has('status_id')) { if ($request->filled('status_id')) {
$assets->where('assets.status_id', '=', $request->input('status_id')); $assets->where('assets.status_id', '=', $request->input('status_id'));
} }
@ -109,40 +109,40 @@ class AssetsController extends Controller
$assets->where('assets.requestable', '=', '1'); $assets->where('assets.requestable', '=', '1');
} }
if ($request->has('model_id')) { if ($request->filled('model_id')) {
$assets->InModelList([$request->input('model_id')]); $assets->InModelList([$request->input('model_id')]);
} }
if ($request->has('category_id')) { if ($request->filled('category_id')) {
$assets->InCategory($request->input('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')); $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')); $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')) $assets->where('assets.assigned_to', '=', $request->input('assigned_to'))
->where('assets.assigned_type', '=', $request->input('assigned_type')); ->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')); $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')); $assets->ByManufacturer($request->input('manufacturer_id'));
} }
if ($request->has('depreciation_id')) { if ($request->filled('depreciation_id')) {
$assets->ByDepreciationId($request->input('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 = request('offset', 0); $offset = request('offset', 0);
$limit = $request->input('limit', 50); $limit = $request->input('limit', 50);
@ -201,7 +201,7 @@ class AssetsController extends Controller
break; break;
default: 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 // terrible workaround for complex-query Laravel bug in fulltext
$assets->join('status_labels AS status_alias',function ($join) { $assets->join('status_labels AS status_alias',function ($join) {
$join->on('status_alias.id', "=", "assets.status_id") $join->on('status_alias.id', "=", "assets.status_id")
@ -220,7 +220,7 @@ class AssetsController extends Controller
if ((!is_null($filter)) && (count($filter)) > 0) { if ((!is_null($filter)) && (count($filter)) > 0) {
$assets->ByFilter($filter); $assets->ByFilter($filter);
} elseif ($request->has('search')) { } elseif ($request->filled('search')) {
$assets->TextSearch($request->input('search')); $assets->TextSearch($request->input('search'));
} }
@ -356,11 +356,11 @@ class AssetsController extends Controller
'assets.status_id' 'assets.status_id'
])->with('model', 'assetstatus', 'assignedTo')->NotArchived()); ])->with('model', 'assetstatus', 'assignedTo')->NotArchived());
if ($request->has('assetStatusType') && $request->input('assetStatusType') === 'RTD') { if ($request->filled('assetStatusType') && $request->input('assetStatusType') === 'RTD') {
$assets = $assets->RTD(); $assets = $assets->RTD();
} }
if ($request->has('search')) { if ($request->filled('search')) {
$assets = $assets->AssignedSearch($request->input('search')); $assets = $assets->AssignedSearch($request->input('search'));
} }
@ -469,48 +469,48 @@ class AssetsController extends Controller
$this->authorize('update', Asset::class); $this->authorize('update', Asset::class);
if ($asset = Asset::find($id)) { if ($asset = Asset::find($id)) {
($request->has('model_id')) ? ($request->filled('model_id')) ?
$asset->model()->associate(AssetModel::find($request->get('model_id'))) : ''; $asset->model()->associate(AssetModel::find($request->get('model_id'))) : '';
($request->has('name')) ? ($request->filled('name')) ?
$asset->name = $request->get('name') : ''; $asset->name = $request->get('name') : '';
($request->has('serial')) ? ($request->filled('serial')) ?
$asset->serial = $request->get('serial') : ''; $asset->serial = $request->get('serial') : '';
($request->has('model_id')) ? ($request->filled('model_id')) ?
$asset->model_id = $request->get('model_id') : ''; $asset->model_id = $request->get('model_id') : '';
($request->has('order_number')) ? ($request->filled('order_number')) ?
$asset->order_number = $request->get('order_number') : ''; $asset->order_number = $request->get('order_number') : '';
($request->has('notes')) ? ($request->filled('notes')) ?
$asset->notes = $request->get('notes') : ''; $asset->notes = $request->get('notes') : '';
($request->has('asset_tag')) ? ($request->filled('asset_tag')) ?
$asset->asset_tag = $request->get('asset_tag') : ''; $asset->asset_tag = $request->get('asset_tag') : '';
($request->has('archived')) ? ($request->filled('archived')) ?
$asset->archived = $request->get('archived') : ''; $asset->archived = $request->get('archived') : '';
($request->has('status_id')) ? ($request->filled('status_id')) ?
$asset->status_id = $request->get('status_id') : ''; $asset->status_id = $request->get('status_id') : '';
($request->has('warranty_months')) ? ($request->filled('warranty_months')) ?
$asset->warranty_months = $request->get('warranty_months') : ''; $asset->warranty_months = $request->get('warranty_months') : '';
($request->has('purchase_cost')) ? ($request->filled('purchase_cost')) ?
$asset->purchase_cost = Helper::ParseFloat($request->get('purchase_cost')) : ''; $asset->purchase_cost = Helper::ParseFloat($request->get('purchase_cost')) : '';
($request->has('purchase_date')) ? ($request->filled('purchase_date')) ?
$asset->purchase_date = $request->get('purchase_date') : ''; $asset->purchase_date = $request->get('purchase_date') : '';
($request->has('assigned_to')) ? ($request->filled('assigned_to')) ?
$asset->assigned_to = $request->get('assigned_to') : ''; $asset->assigned_to = $request->get('assigned_to') : '';
($request->has('supplier_id')) ? ($request->filled('supplier_id')) ?
$asset->supplier_id = $request->get('supplier_id') : ''; $asset->supplier_id = $request->get('supplier_id') : '';
($request->has('requestable')) ? ($request->filled('requestable')) ?
$asset->requestable = $request->get('requestable') : ''; $asset->requestable = $request->get('requestable') : '';
($request->has('rtd_location_id')) ? ($request->filled('rtd_location_id')) ?
$asset->rtd_location_id = $request->get('rtd_location_id') : ''; $asset->rtd_location_id = $request->get('rtd_location_id') : '';
($request->has('rtd_location_id')) ? ($request->filled('rtd_location_id')) ?
$asset->location_id = $request->get('rtd_location_id') : ''; $asset->location_id = $request->get('rtd_location_id') : '';
($request->has('company_id')) ? ($request->filled('company_id')) ?
$asset->company_id = Company::getIdForCurrentUser($request->get('company_id')) : ''; $asset->company_id = Company::getIdForCurrentUser($request->get('company_id')) : '';
// Update custom fields // Update custom fields
if (($model = AssetModel::find($asset->model_id)) && (isset($model->fieldset))) { if (($model = AssetModel::find($asset->model_id)) && (isset($model->fieldset))) {
foreach ($model->fieldset->fields as $field) { foreach ($model->fieldset->fields as $field) {
if ($request->has($field->convertUnicodeDbSlug())) { if ($request->filled($field->convertUnicodeDbSlug())) {
$asset->{$field->convertUnicodeDbSlug()} = e($request->input($field->convertUnicodeDbSlug())); $asset->{$field->convertUnicodeDbSlug()} = e($request->input($field->convertUnicodeDbSlug()));
} }
} }
@ -519,11 +519,11 @@ class AssetsController extends Controller
if ($asset->save()) { 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; $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; $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; $location = $target->id;
} }
@ -678,7 +678,7 @@ class AssetsController extends Controller
$asset->name = Input::get('name'); $asset->name = Input::get('name');
$asset->location_id = $asset->rtd_location_id; $asset->location_id = $asset->rtd_location_id;
if ($request->has('location_id')) { if ($request->filled('location_id')) {
$asset->location_id = $request->input('location_id'); $asset->location_id = $request->input('location_id');
} }

View file

@ -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']) $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'); ->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')); $categories = $categories->TextSearch($request->input('search'));
} }
@ -148,7 +148,7 @@ class CategoriesController extends Controller
'image', 'image',
]); ]);
if ($request->has('search')) { if ($request->filled('search')) {
$categories = $categories->where('name', 'LIKE', '%'.$request->get('search').'%'); $categories = $categories->where('name', 'LIKE', '%'.$request->get('search').'%');
} }

View file

@ -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'); $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')); $companies->TextSearch($request->input('search'));
} }
@ -168,7 +168,7 @@ class CompaniesController extends Controller
'companies.image', 'companies.image',
]); ]);
if ($request->has('search')) { if ($request->filled('search')) {
$companies = $companies->where('companies.name', 'LIKE', '%'.$request->get('search').'%'); $companies = $companies->where('companies.name', 'LIKE', '%'.$request->get('search').'%');
} }

View file

@ -27,19 +27,19 @@ class ComponentsController extends Controller
$components = Company::scopeCompanyables(Component::select('components.*') $components = Company::scopeCompanyables(Component::select('components.*')
->with('company', 'location', 'category')); ->with('company', 'location', 'category'));
if ($request->has('search')) { if ($request->filled('search')) {
$components = $components->TextSearch($request->input('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')); $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')); $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')); $components->where('location_id','=',$request->input('location_id'));
} }

View file

@ -27,15 +27,15 @@ class ConsumablesController extends Controller
->with('company', 'location', 'category', 'users', 'manufacturer') ->with('company', 'location', 'category', 'users', 'manufacturer')
); );
if ($request->has('search')) { if ($request->filled('search')) {
$consumables = $consumables->TextSearch(e($request->input('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')); $consumables->where('company_id','=',$request->input('company_id'));
} }
if ($request->has('manufacturer_id')) { if ($request->filled('manufacturer_id')) {
$consumables->where('manufacturer_id','=',$request->input('manufacturer_id')); $consumables->where('manufacturer_id','=',$request->input('manufacturer_id'));
} }

View file

@ -35,7 +35,7 @@ class DepartmentsController extends Controller
'departments.image' 'departments.image'
])->with('users')->with('location')->with('manager')->with('company')->withCount('users as users_count'); ])->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')); $departments = $departments->TextSearch($request->input('search'));
} }
@ -76,7 +76,7 @@ class DepartmentsController extends Controller
$department = new Department; $department = new Department;
$department->fill($request->all()); $department->fill($request->all());
$department->user_id = Auth::user()->id; $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()) { if ($department->save()) {
return response()->json(Helper::formatStandardApiResponse('success', $department, trans('admin/departments/message.create.success'))); return response()->json(Helper::formatStandardApiResponse('success', $department, trans('admin/departments/message.create.success')));
@ -142,7 +142,7 @@ class DepartmentsController extends Controller
'image', 'image',
]); ]);
if ($request->has('search')) { if ($request->filled('search')) {
$departments = $departments->where('name', 'LIKE', '%'.$request->get('search').'%'); $departments = $departments->where('name', 'LIKE', '%'.$request->get('search').'%');
} }

View file

@ -24,7 +24,7 @@ class DepreciationsController extends Controller
$depreciations = Depreciation::select('id','name','months','user_id','created_at','updated_at'); $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')); $depreciations = $depreciations->TextSearch($request->input('search'));
} }

View file

@ -24,7 +24,7 @@ class GroupsController extends Controller
$groups = Group::select('id','name','permissions','created_at','updated_at')->withCount('users as users_count'); $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')); $groups = $groups->TextSearch($request->input('search'));
} }

View file

@ -28,56 +28,56 @@ class LicensesController extends Controller
$licenses = Company::scopeCompanyables(License::with('company', 'manufacturer', 'freeSeats', 'supplier','category')->withCount('freeSeats as free_seats_count')); $licenses = Company::scopeCompanyables(License::with('company', 'manufacturer', 'freeSeats', 'supplier','category')->withCount('freeSeats as free_seats_count'));
if ($request->has('company_id')) { if ($request->filled('company_id')) {
$licenses->where('company_id','=',$request->input('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')); $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')); $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')); $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')); $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')); $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')); $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')); $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')); $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')); $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')); $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')); $licenses->where('supplier_id','=',$request->input('supplier_id'));
} }
if ($request->has('search')) { if ($request->filled('search')) {
$licenses = $licenses->TextSearch($request->input('search')); $licenses = $licenses->TextSearch($request->input('search'));
} }

View file

@ -45,7 +45,7 @@ class LocationsController extends Controller
->withCount('assets as assets_count') ->withCount('assets as assets_count')
->withCount('users as users_count'); ->withCount('users as users_count');
if ($request->has('search')) { if ($request->filled('search')) {
$locations = $locations->TextSearch($request->input('search')); $locations = $locations->TextSearch($request->input('search'));
} }
@ -173,7 +173,7 @@ class LocationsController extends Controller
'locations.image', 'locations.image',
]); ]);
if ($request->has('search')) { if ($request->filled('search')) {
$locations = $locations->where('locations.name', 'LIKE', '%'.$request->get('search').'%'); $locations = $locations->where('locations.name', 'LIKE', '%'.$request->get('search').'%');
} }

View file

@ -32,7 +32,7 @@ class ManufacturersController extends Controller
$manufacturers->onlyTrashed(); $manufacturers->onlyTrashed();
} }
if ($request->has('search')) { if ($request->filled('search')) {
$manufacturers = $manufacturers->TextSearch($request->input('search')); $manufacturers = $manufacturers->TextSearch($request->input('search'));
} }
@ -145,7 +145,7 @@ class ManufacturersController extends Controller
'image', 'image',
]); ]);
if ($request->has('search')) { if ($request->filled('search')) {
$manufacturers = $manufacturers->where('name', 'LIKE', '%'.$request->get('search').'%'); $manufacturers = $manufacturers->where('name', 'LIKE', '%'.$request->get('search').'%');
} }

View file

@ -22,25 +22,25 @@ class ReportsController extends Controller
$actionlogs = Actionlog::with('item', 'user', 'target','location'); $actionlogs = Actionlog::with('item', 'user', 'target','location');
if ($request->has('search')) { if ($request->filled('search')) {
$actionlogs = $actionlogs->TextSearch(e($request->input('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')) $actionlogs = $actionlogs->where('target_id','=',$request->input('target_id'))
->where('target_type','=',"App\\Models\\".ucwords($request->input('target_type'))); ->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')) $actionlogs = $actionlogs->where('item_id','=',$request->input('item_id'))
->where('item_type','=',"App\\Models\\".ucwords($request->input('item_type'))); ->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'); $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'); $actionlogs = $actionlogs->whereNotNull('filename')->orderBy('created_at', 'desc');
} }

View file

@ -26,7 +26,7 @@ class StatuslabelsController extends Controller
$statuslabels = Statuslabel::withCount('assets as assets_count'); $statuslabels = Statuslabel::withCount('assets as assets_count');
if ($request->has('search')) { if ($request->filled('search')) {
$statuslabels = $statuslabels->TextSearch($request->input('search')); $statuslabels = $statuslabels->TextSearch($request->input('search'));
} }
@ -55,7 +55,7 @@ class StatuslabelsController extends Controller
$this->authorize('create', Statuslabel::class); $this->authorize('create', Statuslabel::class);
$request->except('deployable', 'pending','archived'); $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); 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'); $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.')); return response()->json(Helper::formatStandardApiResponse('error', null, 'Status label type is required.'));
} }

View file

@ -29,7 +29,7 @@ class SuppliersController extends Controller
)->withCount('assets as assets_count')->withCount('licenses as licenses_count')->withCount('accessories as accessories_count'); )->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')); $suppliers = $suppliers->TextSearch($request->input('search'));
} }
@ -153,7 +153,7 @@ class SuppliersController extends Controller
'image', 'image',
]); ]);
if ($request->has('search')) { if ($request->filled('search')) {
$suppliers = $suppliers->where('suppliers.name', 'LIKE', '%'.$request->get('search').'%'); $suppliers = $suppliers->where('suppliers.name', 'LIKE', '%'.$request->get('search').'%');
} }

View file

@ -60,27 +60,27 @@ class UsersController extends Controller
$users = Company::scopeCompanyables($users); $users = Company::scopeCompanyables($users);
if (($request->has('deleted')) && ($request->input('deleted')=='true')) { if (($request->filled('deleted')) && ($request->input('deleted')=='true')) {
$users = $users->GetDeleted(); $users = $users->GetDeleted();
} }
if ($request->has('company_id')) { if ($request->filled('company_id')) {
$users = $users->where('users.company_id', '=', $request->input('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')); $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')); $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')); $users = $users->where('users.department_id','=',$request->input('department_id'));
} }
if ($request->has('search')) { if ($request->filled('search')) {
$users = $users->TextSearch($request->input('search')); $users = $users->TextSearch($request->input('search'));
} }
@ -146,7 +146,7 @@ class UsersController extends Controller
$users = Company::scopeCompanyables($users); $users = Company::scopeCompanyables($users);
if ($request->has('search')) { if ($request->filled('search')) {
$users = $users->where('first_name', 'LIKE', '%'.$request->get('search').'%') $users = $users->where('first_name', 'LIKE', '%'.$request->get('search').'%')
->orWhere('last_name', 'LIKE', '%'.$request->get('search').'%') ->orWhere('last_name', 'LIKE', '%'.$request->get('search').'%')
->orWhere('username', 'LIKE', '%'.$request->get('search').'%') ->orWhere('username', 'LIKE', '%'.$request->get('search').'%')
@ -240,7 +240,7 @@ class UsersController extends Controller
return response()->json(Helper::formatStandardApiResponse('error', null, 'You cannot be your own manager')); 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')); $user->password = bcrypt($request->input('password'));
} }
@ -309,7 +309,7 @@ class UsersController extends Controller
$this->authorize('update', User::class); $this->authorize('update', User::class);
if ($request->has('id')) { if ($request->filled('id')) {
try { try {
$user = User::find($request->get('id')); $user = User::find($request->get('id'));
$user->two_factor_secret = null; $user->two_factor_secret = null;

View file

@ -70,13 +70,13 @@ class AssetCheckinController extends Controller
$asset->accepted = null; $asset->accepted = null;
$asset->name = e($request->get('name')); $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->status_id = e($request->get('status_id'));
} }
$asset->location_id = $asset->rtd_location_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')); $asset->location_id = e($request->get('location_id'));
} }

View file

@ -73,12 +73,12 @@ class AssetCheckoutController extends Controller
$asset = $this->updateAssetLocation($asset, $target); $asset = $this->updateAssetLocation($asset, $target);
$checkout_at = date("Y-m-d H:i:s"); $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'); $checkout_at = $request->get('checkout_at');
} }
$expected_checkin = ''; $expected_checkin = '';
if ($request->has('expected_checkin')) { if ($request->filled('expected_checkin')) {
$expected_checkin = $request->get('expected_checkin'); $expected_checkin = $request->get('expected_checkin');
} }

View file

@ -31,7 +31,7 @@ class AssetFilesController extends Controller
$destinationPath = config('app.private_uploads').'/assets'; $destinationPath = config('app.private_uploads').'/assets';
if ($request->hasFile('file')) { if ($request->filledFile('file')) {
foreach ($request->file('file') as $file) { foreach ($request->file('file') as $file) {
$extension = $file->getClientOriginalExtension(); $extension = $file->getClientOriginalExtension();
$filename = 'hardware-'.$asset->id.'-'.str_random(8); $filename = 'hardware-'.$asset->id.'-'.str_random(8);

View file

@ -67,7 +67,7 @@ class AssetsController extends Controller
public function index(Request $request) public function index(Request $request)
{ {
$this->authorize('index', Asset::class); $this->authorize('index', Asset::class);
if ($request->has('company_id')) { if ($request->filled('company_id')) {
$company = Company::find($request->input('company_id')); $company = Company::find($request->input('company_id'));
} else { } else {
$company = null; $company = null;
@ -92,7 +92,7 @@ class AssetsController extends Controller
->with('item', new Asset) ->with('item', new Asset)
->with('statuslabel_types', Helper::statusTypeList()); ->with('statuslabel_types', Helper::statusTypeList());
if ($request->has('model_id')) { if ($request->filled('model_id')) {
$selected_model = AssetModel::find($request->input('model_id')); $selected_model = AssetModel::find($request->input('model_id'));
$view->with('selected_model', $selected_model); $view->with('selected_model', $selected_model);
} }
@ -139,7 +139,7 @@ class AssetsController extends Controller
} }
// Create the image (if one was chosen.) // Create the image (if one was chosen.)
if ($request->hasFile('image')) { if ($request->filledFile('image')) {
$image = $request->input('image'); $image = $request->input('image');
// After modification, the image is prefixed by mime info like the following: // After modification, the image is prefixed by mime info like the following:
@ -309,7 +309,7 @@ class AssetsController extends Controller
$asset->supplier_id = $request->input('supplier_id', null); $asset->supplier_id = $request->input('supplier_id', null);
// If the box isn't checked, it's not in the request at all. // 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); $asset->rtd_location_id = $request->input('rtd_location_id', null);
if ($asset->assigned_to=='') { if ($asset->assigned_to=='') {
@ -317,7 +317,7 @@ class AssetsController extends Controller
} }
if ($request->has('image_delete')) { if ($request->filled('image_delete')) {
try { try {
unlink(public_path().'/uploads/assets/'.$asset->image); unlink(public_path().'/uploads/assets/'.$asset->image);
$asset->image = ''; $asset->image = '';
@ -339,7 +339,7 @@ class AssetsController extends Controller
$asset->physical = '1'; $asset->physical = '1';
// Update the image // Update the image
if ($request->has('image')) { if ($request->filled('image')) {
$image = $request->input('image'); $image = $request->input('image');
// See postCreate for more explaination of the following. // See postCreate for more explaination of the following.
$header = explode(';', $image, 2)[0]; $header = explode(';', $image, 2)[0];
@ -769,7 +769,7 @@ class AssetsController extends Controller
$filename = ''; $filename = '';
if ($request->hasFile('image')) { if ($request->filledFile('image')) {
$file = $request->file('image'); $file = $request->file('image');
try { try {
$destinationPath = config('app.private_uploads').'/audits'; $destinationPath = config('app.private_uploads').'/audits';

View file

@ -29,13 +29,13 @@ class BulkAssetsController extends Controller
{ {
$this->authorize('update', Asset::class); $this->authorize('update', Asset::class);
if (!$request->has('ids')) { if (!$request->filled('ids')) {
return redirect()->back()->with('error', 'No assets selected'); return redirect()->back()->with('error', 'No assets selected');
} }
$asset_ids = array_keys($request->input('ids')); $asset_ids = array_keys($request->input('ids'));
if ($request->has('bulk_actions')) { if ($request->filled('bulk_actions')) {
switch($request->input('bulk_actions')) { switch($request->input('bulk_actions')) {
case 'labels': case 'labels':
return view('hardware/labels') return view('hardware/labels')
@ -71,22 +71,22 @@ class BulkAssetsController extends Controller
\Log::debug($request->input('ids')); \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.')); return redirect()->route("hardware.index")->with('warning', trans('No assets selected, so nothing was updated.'));
} }
$assets = array_keys($request->input('ids')); $assets = array_keys($request->input('ids'));
if (($request->has('purchase_date')) if (($request->filled('purchase_date'))
|| ($request->has('purchase_cost')) || ($request->filled('purchase_cost'))
|| ($request->has('supplier_id')) || ($request->filled('supplier_id'))
|| ($request->has('order_number')) || ($request->filled('order_number'))
|| ($request->has('warranty_months')) || ($request->filled('warranty_months'))
|| ($request->has('rtd_location_id')) || ($request->filled('rtd_location_id'))
|| ($request->has('requestable')) || ($request->filled('requestable'))
|| ($request->has('company_id')) || ($request->filled('company_id'))
|| ($request->has('status_id')) || ($request->filled('status_id'))
|| ($request->has('model_id')) || ($request->filled('model_id'))
) { ) {
foreach ($assets as $assetId) { foreach ($assets as $assetId) {
$this->update_array = []; $this->update_array = [];
@ -99,20 +99,20 @@ class BulkAssetsController extends Controller
->conditionallyAddItem('supplier_id') ->conditionallyAddItem('supplier_id')
->conditionallyAddItem('warranty_months'); ->conditionallyAddItem('warranty_months');
if ($request->has('purchase_cost')) { if ($request->filled('purchase_cost')) {
$this->update_array['purchase_cost'] = Helper::ParseFloat($request->input('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'); $this->update_array['company_id'] = $request->input('company_id');
if ($request->input('company_id')=="clear") { if ($request->input('company_id')=="clear") {
$this->update_array['company_id'] = null; $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'); $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'); $this->update_array['location_id'] = $request->input('rtd_location_id');
} }
} }
@ -161,7 +161,7 @@ class BulkAssetsController extends Controller
{ {
$this->authorize('delete', Asset::class); $this->authorize('delete', Asset::class);
if ($request->has('ids')) { if ($request->filled('ids')) {
$assets = Asset::find($request->get('ids')); $assets = Asset::find($request->get('ids'));
foreach ($assets as $asset) { foreach ($assets as $asset) {
$update_array['deleted_at'] = date('Y-m-d H:i:s'); $update_array['deleted_at'] = date('Y-m-d H:i:s');
@ -212,13 +212,13 @@ class BulkAssetsController extends Controller
} }
} }
$checkout_at = date("Y-m-d H:i:s"); $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')); $checkout_at = e($request->get('checkout_at'));
} }
$expected_checkin = ''; $expected_checkin = '';
if ($request->has('expected_checkin')) { if ($request->filled('expected_checkin')) {
$expected_checkin = e($request->get('expected_checkin')); $expected_checkin = e($request->get('expected_checkin'));
} }

View file

@ -67,10 +67,10 @@ class BulkAssetModelsController extends Controller
$models_raw_array = Input::get('ids'); $models_raw_array = Input::get('ids');
$update_array = array(); $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'); $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'); $update_array['category_id'] = $request->input('category_id');
} }
if ($request->input('fieldset_id')!='NC') { if ($request->input('fieldset_id')!='NC') {

View file

@ -81,7 +81,7 @@ class CustomFieldsController extends Controller
]); ]);
if ($request->has("custom_format")) { if ($request->filled("custom_format")) {
$field->format = e($request->get("custom_format")); $field->format = e($request->get("custom_format"));
} else { } else {
$field->format = e($request->get("format")); $field->format = e($request->get("format"));

View file

@ -31,7 +31,7 @@ class DepartmentsController extends Controller
{ {
$this->authorize('index', Department::class); $this->authorize('index', Department::class);
$company = null; $company = null;
if ($request->has('company_id')) { if ($request->filled('company_id')) {
$company = Company::find($request->input('company_id')); $company = Company::find($request->input('company_id'));
} }
return view('departments/index')->with('company', $company); return view('departments/index')->with('company', $company);
@ -159,7 +159,7 @@ class DepartmentsController extends Controller
$this->authorize('update', $department); $this->authorize('update', $department);
$department->fill($request->all()); $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);
$department = $request->handleImages($department); $department = $request->handleImages($department);

View file

@ -314,65 +314,65 @@ class ReportsController extends Controller
// Open output stream // Open output stream
$handle = fopen('php://output', 'w'); $handle = fopen('php://output', 'w');
if ($request->has('use_bom')) { if ($request->filled('use_bom')) {
fprintf($handle, chr(0xEF) . chr(0xBB) . chr(0xBF)); fprintf($handle, chr(0xEF) . chr(0xBB) . chr(0xBF));
} }
$header = []; $header = [];
if ($request->has('company')) { if ($request->filled('company')) {
$header[] = trans('general.company'); $header[] = trans('general.company');
} }
if ($request->has('asset_name')) { if ($request->filled('asset_name')) {
$header[] = trans('admin/hardware/form.name'); $header[] = trans('admin/hardware/form.name');
} }
if ($request->has('asset_tag')) { if ($request->filled('asset_tag')) {
$header[] = trans('admin/hardware/table.asset_tag'); $header[] = trans('admin/hardware/table.asset_tag');
} }
if ($request->has('model')) { if ($request->filled('model')) {
$header[] = trans('admin/hardware/form.model'); $header[] = trans('admin/hardware/form.model');
$header[] = trans('general.model_no'); $header[] = trans('general.model_no');
} }
if ($request->has('category')) { if ($request->filled('category')) {
$header[] = trans('general.category'); $header[] = trans('general.category');
} }
if ($request->has('manufacturer')) { if ($request->filled('manufacturer')) {
$header[] = trans('admin/hardware/form.manufacturer'); $header[] = trans('admin/hardware/form.manufacturer');
} }
if ($request->has('serial')) { if ($request->filled('serial')) {
$header[] = trans('admin/hardware/table.serial'); $header[] = trans('admin/hardware/table.serial');
} }
if ($request->has('purchase_date')) { if ($request->filled('purchase_date')) {
$header[] = trans('admin/hardware/table.purchase_date'); $header[] = trans('admin/hardware/table.purchase_date');
} }
if (($request->has('purchase_cost')) || ($request->has('depreciation'))) { if (($request->filled('purchase_cost')) || ($request->filled('depreciation'))) {
$header[] = trans('admin/hardware/table.purchase_cost'); $header[] = trans('admin/hardware/table.purchase_cost');
} }
if ($request->has('eol')) { if ($request->filled('eol')) {
$header[] = trans('admin/hardware/table.eol'); $header[] = trans('admin/hardware/table.eol');
} }
if ($request->has('order')) { if ($request->filled('order')) {
$header[] = trans('admin/hardware/form.order'); $header[] = trans('admin/hardware/form.order');
} }
if ($request->has('supplier')) { if ($request->filled('supplier')) {
$header[] = trans('general.supplier'); $header[] = trans('general.supplier');
} }
if ($request->has('location')) { if ($request->filled('location')) {
$header[] = trans('admin/hardware/table.location'); $header[] = trans('admin/hardware/table.location');
} }
if ($request->has('location_address')) { if ($request->filled('location_address')) {
$header[] = trans('general.address'); $header[] = trans('general.address');
$header[] = trans('general.address'); $header[] = trans('general.address');
$header[] = trans('general.city'); $header[] = trans('general.city');
@ -381,11 +381,11 @@ class ReportsController extends Controller
$header[] = trans('general.zip'); $header[] = trans('general.zip');
} }
if ($request->has('rtd_location')) { if ($request->filled('rtd_location')) {
$header[] = trans('admin/hardware/form.default_location'); $header[] = trans('admin/hardware/form.default_location');
} }
if ($request->has('rtd_location_address')) { if ($request->filled('rtd_location_address')) {
$header[] = trans('general.address'); $header[] = trans('general.address');
$header[] = trans('general.address'); $header[] = trans('general.address');
$header[] = trans('general.city'); $header[] = trans('general.city');
@ -395,65 +395,65 @@ class ReportsController extends Controller
} }
if ($request->has('assigned_to')) { if ($request->filled('assigned_to')) {
$header[] = trans('admin/hardware/table.checkoutto'); $header[] = trans('admin/hardware/table.checkoutto');
$header[] = trans('general.type'); $header[] = trans('general.type');
} }
if ($request->has('username')) { if ($request->filled('username')) {
$header[] = 'Username'; $header[] = 'Username';
} }
if ($request->has('employee_num')) { if ($request->filled('employee_num')) {
$header[] = 'Employee No.'; $header[] = 'Employee No.';
} }
if ($request->has('manager')) { if ($request->filled('manager')) {
$header[] = trans('admin/users/table.manager'); $header[] = trans('admin/users/table.manager');
} }
if ($request->has('department')) { if ($request->filled('department')) {
$header[] = trans('general.department'); $header[] = trans('general.department');
} }
if ($request->has('status')) { if ($request->filled('status')) {
$header[] = trans('general.status'); $header[] = trans('general.status');
} }
if ($request->has('warranty')) { if ($request->filled('warranty')) {
$header[] = 'Warranty'; $header[] = 'Warranty';
$header[] = 'Warranty Expires'; $header[] = 'Warranty Expires';
} }
if ($request->has('depreciation')) { if ($request->filled('depreciation')) {
$header[] = 'Value'; $header[] = 'Value';
$header[] = 'Diff'; $header[] = 'Diff';
} }
if ($request->has('checkout_date')) { if ($request->filled('checkout_date')) {
$header[] = trans('admin/hardware/table.checkout_date'); $header[] = trans('admin/hardware/table.checkout_date');
} }
if ($request->has('expected_checkin')) { if ($request->filled('expected_checkin')) {
$header[] = trans('admin/hardware/form.expected_checkin'); $header[] = trans('admin/hardware/form.expected_checkin');
} }
if ($request->has('created_at')) { if ($request->filled('created_at')) {
$header[] = trans('general.created_at'); $header[] = trans('general.created_at');
} }
if ($request->has('updated_at')) { if ($request->filled('updated_at')) {
$header[] = trans('general.updated_at'); $header[] = trans('general.updated_at');
} }
if ($request->has('last_audit_date')) { if ($request->filled('last_audit_date')) {
$header[] = trans('general.last_audit'); $header[] = trans('general.last_audit');
} }
if ($request->has('next_audit_date')) { if ($request->filled('next_audit_date')) {
$header[] = trans('general.next_audit_date'); $header[] = trans('general.next_audit_date');
} }
if ($request->has('notes')) { if ($request->filled('notes')) {
$header[] = trans('general.notes'); $header[] = trans('general.notes');
} }
@ -471,52 +471,52 @@ class ReportsController extends Controller
'location', 'assetstatus', 'assetlog', 'company', 'defaultLoc','assignedTo', 'location', 'assetstatus', 'assetlog', 'company', 'defaultLoc','assignedTo',
'model.category', 'model.manufacturer','supplier'); 'model.category', 'model.manufacturer','supplier');
if ($request->has('by_location_id')) { if ($request->filled('by_location_id')) {
$assets->where('assets.location_id', $request->input('by_location_id')); $assets->where('assets.location_id', $request->input('by_location_id'));
} }
if ($request->has('by_rtd_location_id')) { if ($request->filled('by_rtd_location_id')) {
\Log::debug('RTD location should match: '.$request->input('by_rtd_location_id')); \Log::debug('RTD location should match: '.$request->input('by_rtd_location_id'));
$assets->where('assets.rtd_location_id', $request->input('by_rtd_location_id')); $assets->where('assets.rtd_location_id', $request->input('by_rtd_location_id'));
} }
if ($request->has('by_supplier_id')) { if ($request->filled('by_supplier_id')) {
$assets->where('assets.supplier_id', $request->input('by_supplier_id')); $assets->where('assets.supplier_id', $request->input('by_supplier_id'));
} }
if ($request->has('by_company_id')) { if ($request->filled('by_company_id')) {
$assets->where('assets.company_id', $request->input('by_company_id')); $assets->where('assets.company_id', $request->input('by_company_id'));
} }
if ($request->has('by_model_id')) { if ($request->filled('by_model_id')) {
$assets->where('assets.model_id', $request->input('by_model_id')); $assets->where('assets.model_id', $request->input('by_model_id'));
} }
if ($request->has('by_category_id')) { if ($request->filled('by_category_id')) {
$assets->InCategory($request->input('by_category_id')); $assets->InCategory($request->input('by_category_id'));
} }
if ($request->has('by_manufacturer_id')) { if ($request->filled('by_manufacturer_id')) {
$assets->ByManufacturer($request->input('by_manufacturer_id')); $assets->ByManufacturer($request->input('by_manufacturer_id'));
} }
if ($request->has('by_order_number')) { if ($request->filled('by_order_number')) {
$assets->where('assets.order_number', $request->input('by_order_number')); $assets->where('assets.order_number', $request->input('by_order_number'));
} }
if ($request->has('by_status_id')) { if ($request->filled('by_status_id')) {
$assets->where('assets.status_id', $request->input('by_status_id')); $assets->where('assets.status_id', $request->input('by_status_id'));
} }
if (($request->has('purchase_start')) && ($request->has('purchase_end'))) { if (($request->filled('purchase_start')) && ($request->filled('purchase_end'))) {
$assets->whereBetween('assets.purchase_date', [$request->input('purchase_start'), $request->input('purchase_end')]); $assets->whereBetween('assets.purchase_date', [$request->input('purchase_start'), $request->input('purchase_end')]);
} }
if (($request->has('created_start')) && ($request->has('created_end'))) { if (($request->filled('created_start')) && ($request->filled('created_end'))) {
$assets->whereBetween('assets.created_at', [$request->input('created_start'), $request->input('created_end')]); $assets->whereBetween('assets.created_at', [$request->input('created_start'), $request->input('created_end')]);
} }
if (($request->has('expected_checkin_start')) && ($request->has('expected_checkin_end'))) { if (($request->filled('expected_checkin_start')) && ($request->filled('expected_checkin_end'))) {
$assets->whereBetween('assets.expected_checkin', [$request->input('expected_checkin_start'), $request->input('expected_checkin_end')]); $assets->whereBetween('assets.expected_checkin', [$request->input('expected_checkin_start'), $request->input('expected_checkin_end')]);
} }
@ -525,61 +525,61 @@ class ReportsController extends Controller
foreach ($assets as $asset) { foreach ($assets as $asset) {
$row = []; $row = [];
if ($request->has('company')) { if ($request->filled('company')) {
$row[] = ($asset->company) ? $asset->company->name : ''; $row[] = ($asset->company) ? $asset->company->name : '';
} }
if ($request->has('asset_name')) { if ($request->filled('asset_name')) {
$row[] = ($asset->name) ? $asset->name : ''; $row[] = ($asset->name) ? $asset->name : '';
} }
if ($request->has('asset_tag')) { if ($request->filled('asset_tag')) {
$row[] = ($asset->asset_tag) ? $asset->asset_tag : ''; $row[] = ($asset->asset_tag) ? $asset->asset_tag : '';
} }
if ($request->has('model')) { if ($request->filled('model')) {
$row[] = ($asset->model) ? $asset->model->name : ''; $row[] = ($asset->model) ? $asset->model->name : '';
$row[] = ($asset->model) ? $asset->model->model_number : ''; $row[] = ($asset->model) ? $asset->model->model_number : '';
} }
if ($request->has('category')) { if ($request->filled('category')) {
$row[] = (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : ''; $row[] = (($asset->model) && ($asset->model->category)) ? $asset->model->category->name : '';
} }
if ($request->has('manufacturer')) { if ($request->filled('manufacturer')) {
$row[] = ($asset->model && $asset->model->manufacturer) ? $asset->model->manufacturer->name : ''; $row[] = ($asset->model && $asset->model->manufacturer) ? $asset->model->manufacturer->name : '';
} }
if ($request->has('serial')) { if ($request->filled('serial')) {
$row[] = ($asset->serial) ? $asset->serial : ''; $row[] = ($asset->serial) ? $asset->serial : '';
} }
if ($request->has('purchase_date')) { if ($request->filled('purchase_date')) {
$row[] = ($asset->purchase_date) ? $asset->purchase_date : ''; $row[] = ($asset->purchase_date) ? $asset->purchase_date : '';
} }
if ($request->has('purchase_cost')) { if ($request->filled('purchase_cost')) {
$row[] = ($asset->purchase_cost) ? Helper::formatCurrencyOutput($asset->purchase_cost) : ''; $row[] = ($asset->purchase_cost) ? Helper::formatCurrencyOutput($asset->purchase_cost) : '';
} }
if ($request->has('eol')) { if ($request->filled('eol')) {
$row[] = ($asset->purchase_date!='') ? $asset->present()->eol_date() : ''; $row[] = ($asset->purchase_date!='') ? $asset->present()->eol_date() : '';
} }
if ($request->has('order')) { if ($request->filled('order')) {
$row[] = ($asset->order_number) ? $asset->order_number : ''; $row[] = ($asset->order_number) ? $asset->order_number : '';
} }
if ($request->has('supplier')) { if ($request->filled('supplier')) {
$row[] = ($asset->supplier) ? $asset->supplier->name : ''; $row[] = ($asset->supplier) ? $asset->supplier->name : '';
} }
if ($request->has('location')) { if ($request->filled('location')) {
$row[] = ($asset->location) ? $asset->location->present()->name() : ''; $row[] = ($asset->location) ? $asset->location->present()->name() : '';
} }
if ($request->has('location_address')) { if ($request->filled('location_address')) {
$row[] = ($asset->location) ? $asset->location->address : ''; $row[] = ($asset->location) ? $asset->location->address : '';
$row[] = ($asset->location) ? $asset->location->address2 : ''; $row[] = ($asset->location) ? $asset->location->address2 : '';
$row[] = ($asset->location) ? $asset->location->city : ''; $row[] = ($asset->location) ? $asset->location->city : '';
@ -588,11 +588,11 @@ class ReportsController extends Controller
$row[] = ($asset->location) ? $asset->location->zip : ''; $row[] = ($asset->location) ? $asset->location->zip : '';
} }
if ($request->has('rtd_location')) { if ($request->filled('rtd_location')) {
$row[] = ($asset->defaultLoc) ? $asset->defaultLoc->present()->name() : ''; $row[] = ($asset->defaultLoc) ? $asset->defaultLoc->present()->name() : '';
} }
if ($request->has('rtd_location_address')) { if ($request->filled('rtd_location_address')) {
$row[] = ($asset->defaultLoc) ? $asset->defaultLoc->address : ''; $row[] = ($asset->defaultLoc) ? $asset->defaultLoc->address : '';
$row[] = ($asset->defaultLoc) ? $asset->defaultLoc->address2 : ''; $row[] = ($asset->defaultLoc) ? $asset->defaultLoc->address2 : '';
$row[] = ($asset->defaultLoc) ? $asset->defaultLoc->city : ''; $row[] = ($asset->defaultLoc) ? $asset->defaultLoc->city : '';
@ -602,12 +602,12 @@ class ReportsController extends Controller
} }
if ($request->has('assigned_to')) { if ($request->filled('assigned_to')) {
$row[] = ($asset->checkedOutToUser() && $asset->assigned) ? e($asset->assigned->getFullNameAttribute()) : ($asset->assigned ? e($asset->assigned->display_name) : ''); $row[] = ($asset->checkedOutToUser() && $asset->assigned) ? e($asset->assigned->getFullNameAttribute()) : ($asset->assigned ? e($asset->assigned->display_name) : '');
$row[] = ($asset->checkedOutToUser() && $asset->assigned) ? 'user' : e($asset->assignedType()); $row[] = ($asset->checkedOutToUser() && $asset->assigned) ? 'user' : e($asset->assignedType());
} }
if ($request->has('username')) { if ($request->filled('username')) {
// Only works if we're checked out to a user, not anything else. // Only works if we're checked out to a user, not anything else.
if ($asset->checkedOutToUser()) { if ($asset->checkedOutToUser()) {
$row[] = ($asset->assignedto) ? $asset->assignedto->username : ''; $row[] = ($asset->assignedto) ? $asset->assignedto->username : '';
@ -616,7 +616,7 @@ class ReportsController extends Controller
} }
} }
if ($request->has('employee_num')) { if ($request->filled('employee_num')) {
// Only works if we're checked out to a user, not anything else. // Only works if we're checked out to a user, not anything else.
if ($asset->checkedOutToUser()) { if ($asset->checkedOutToUser()) {
$row[] = ($asset->assignedto) ? $asset->assignedto->employee_num : ''; $row[] = ($asset->assignedto) ? $asset->assignedto->employee_num : '';
@ -625,7 +625,7 @@ class ReportsController extends Controller
} }
} }
if ($request->has('manager')) { if ($request->filled('manager')) {
if ($asset->checkedOutToUser()) { if ($asset->checkedOutToUser()) {
$row[] = (($asset->assignedto) && ($asset->assignedto->manager)) ? $asset->assignedto->manager->present()->fullName : ''; $row[] = (($asset->assignedto) && ($asset->assignedto->manager)) ? $asset->assignedto->manager->present()->fullName : '';
} else { } else {
@ -634,7 +634,7 @@ class ReportsController extends Controller
} }
if ($request->has('department')) { if ($request->filled('department')) {
if ($asset->checkedOutToUser()) { if ($asset->checkedOutToUser()) {
$row[] = (($asset->assignedto) && ($asset->assignedto->department)) ? $asset->assignedto->department->name : ''; $row[] = (($asset->assignedto) && ($asset->assignedto->department)) ? $asset->assignedto->department->name : '';
} else { } else {
@ -642,55 +642,55 @@ class ReportsController extends Controller
} }
} }
if ($request->has('status')) { if ($request->filled('status')) {
$row[] = ($asset->assetstatus) ? $asset->assetstatus->name.' ('.$asset->present()->statusMeta.')' : ''; $row[] = ($asset->assetstatus) ? $asset->assetstatus->name.' ('.$asset->present()->statusMeta.')' : '';
} }
if ($request->has('warranty')) { if ($request->filled('warranty')) {
$row[] = ($asset->warranty_months) ? $asset->warranty_months : ''; $row[] = ($asset->warranty_months) ? $asset->warranty_months : '';
$row[] = $asset->present()->warrantee_expires(); $row[] = $asset->present()->warrantee_expires();
} }
if ($request->has('depreciation')) { if ($request->filled('depreciation')) {
$depreciation = $asset->getDepreciatedValue(); $depreciation = $asset->getDepreciatedValue();
$diff = ($asset->purchase_cost - $depreciation); $diff = ($asset->purchase_cost - $depreciation);
$row[] = Helper::formatCurrencyOutput($depreciation); $row[] = Helper::formatCurrencyOutput($depreciation);
$row[] = Helper::formatCurrencyOutput($diff); $row[] = Helper::formatCurrencyOutput($diff);
} }
if ($request->has('checkout_date')) { if ($request->filled('checkout_date')) {
$row[] = ($asset->last_checkout) ? $asset->last_checkout : ''; $row[] = ($asset->last_checkout) ? $asset->last_checkout : '';
} }
if ($request->has('expected_checkin')) { if ($request->filled('expected_checkin')) {
$row[] = ($asset->expected_checkin) ? $asset->expected_checkin : ''; $row[] = ($asset->expected_checkin) ? $asset->expected_checkin : '';
} }
if ($request->has('created_at')) { if ($request->filled('created_at')) {
$row[] = ($asset->created_at) ? $asset->created_at : ''; $row[] = ($asset->created_at) ? $asset->created_at : '';
} }
if ($request->has('updated_at')) { if ($request->filled('updated_at')) {
$row[] = ($asset->updated_at) ? $asset->updated_at : ''; $row[] = ($asset->updated_at) ? $asset->updated_at : '';
} }
if ($request->has('last_audit_date')) { if ($request->filled('last_audit_date')) {
$row[] = ($asset->last_audit_date) ? $asset->last_audit_date : ''; $row[] = ($asset->last_audit_date) ? $asset->last_audit_date : '';
} }
if ($request->has('next_audit_date')) { if ($request->filled('next_audit_date')) {
$row[] = ($asset->next_audit_date) ? $asset->next_audit_date : ''; $row[] = ($asset->next_audit_date) ? $asset->next_audit_date : '';
} }
if ($request->has('notes')) { if ($request->filled('notes')) {
$row[] = ($asset->notes) ? $asset->notes : ''; $row[] = ($asset->notes) ? $asset->notes : '';
} }
foreach ($customfields as $customfield) { foreach ($customfields as $customfield) {
$column_name = $customfield->db_column_name(); $column_name = $customfield->db_column_name();
if ($request->has($customfield->db_column_name())) { if ($request->filled($customfield->db_column_name())) {
$row[] = $asset->$column_name; $row[] = $asset->$column_name;
} }
} }

View file

@ -326,7 +326,7 @@ class SettingsController extends Controller
$setting->modellist_displays = ''; $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')); $setting->modellist_displays = implode(',', $request->input('show_in_model_list'));
} }
@ -419,7 +419,7 @@ class SettingsController extends Controller
$setting->brand = 1; $setting->brand = 1;
// If they are uploading an image, validate it and upload it // If they are uploading an image, validate it and upload it
} elseif ($request->hasFile('image')) { } elseif ($request->filledFile('image')) {
if (!config('app.lock_passwords')) { if (!config('app.lock_passwords')) {
$image = $request->file('image'); $image = $request->file('image');
@ -496,7 +496,7 @@ class SettingsController extends Controller
$setting->pwd_secure_complexity = ''; $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')); $setting->pwd_secure_complexity = implode('|', $request->input('pwd_secure_complexity'));
} }
@ -795,31 +795,31 @@ class SettingsController extends Controller
if ($request->has('labels_display_name')) { if ($request->filled('labels_display_name')) {
$setting->labels_display_name = 1; $setting->labels_display_name = 1;
} else { } else {
$setting->labels_display_name = 0; $setting->labels_display_name = 0;
} }
if ($request->has('labels_display_serial')) { if ($request->filled('labels_display_serial')) {
$setting->labels_display_serial = 1; $setting->labels_display_serial = 1;
} else { } else {
$setting->labels_display_serial = 0; $setting->labels_display_serial = 0;
} }
if ($request->has('labels_display_tag')) { if ($request->filled('labels_display_tag')) {
$setting->labels_display_tag = 1; $setting->labels_display_tag = 1;
} else { } else {
$setting->labels_display_tag = 0; $setting->labels_display_tag = 0;
} }
if ($request->has('labels_display_tag')) { if ($request->filled('labels_display_tag')) {
$setting->labels_display_tag = 1; $setting->labels_display_tag = 1;
} else { } else {
$setting->labels_display_tag = 0; $setting->labels_display_tag = 0;
} }
if ($request->has('labels_display_model')) { if ($request->filled('labels_display_model')) {
$setting->labels_display_model = 1; $setting->labels_display_model = 1;
} else { } else {
$setting->labels_display_model = 0; $setting->labels_display_model = 0;

View file

@ -71,7 +71,7 @@ class StatuslabelsController extends Controller
// create a new model instance // create a new model instance
$statusLabel = new Statuslabel(); $statusLabel = new Statuslabel();
if (!$request->has('statuslabel_types')) { if (!$request->filled('statuslabel_types')) {
return redirect()->back()->withInput()->withErrors(['statuslabel_types' => trans('validation.statuslabel_type')]); return redirect()->back()->withInput()->withErrors(['statuslabel_types' => trans('validation.statuslabel_type')]);
} }
@ -136,7 +136,7 @@ class StatuslabelsController extends Controller
return redirect()->route('statuslabels.index')->with('error', trans('admin/statuslabels/message.does_not_exist')); 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')]); return redirect()->back()->withInput()->withErrors(['statuslabel_types' => trans('validation.statuslabel_type')]);
} }

View file

@ -30,7 +30,7 @@ class BulkUsersController extends Controller
{ {
$this->authorize('update', User::class); $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(); $statuslabel_list = Helper::statusLabelList();
$users = User::whereIn('id', array_keys(request('ids'))) $users = User::whereIn('id', array_keys(request('ids')))
->with('groups', 'assets', 'licenses', 'accessories')->get(); ->with('groups', 'assets', 'licenses', 'accessories')->get();
@ -58,7 +58,7 @@ class BulkUsersController extends Controller
{ {
$this->authorize('update', User::class); $this->authorize('update', User::class);
if((!$request->has('ids')) || $request->input('ids') <= 0) { if((!$request->filled('ids')) || $request->input('ids') <= 0) {
return redirect()->back()->with('error', 'No users selected'); return redirect()->back()->with('error', 'No users selected');
} }
$user_raw_array = $request->input('ids'); $user_raw_array = $request->input('ids');
@ -96,7 +96,7 @@ class BulkUsersController extends Controller
->where('id', '!=', Auth::id())->update($this->update_array); ->where('id', '!=', Auth::id())->update($this->update_array);
// Only sync groups if groups were selected // Only sync groups if groups were selected
if ($request->has('groups')) { if ($request->filled('groups')) {
foreach ($users as $user) { foreach ($users as $user) {
$user->groups()->sync($request->input('groups')); $user->groups()->sync($request->input('groups'));
} }
@ -138,10 +138,10 @@ class BulkUsersController extends Controller
{ {
$this->authorize('update', User::class); $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'); return redirect()->back()->with('error', 'No users selected');
} }
if ((!$request->has('status_id')) || ($request->input('status_id')=='')) { if ((!$request->filled('status_id')) || ($request->input('status_id')=='')) {
return redirect()->route('users.index')->with('error', 'No status selected'); return redirect()->route('users.index')->with('error', 'No status selected');
} }

View file

@ -110,7 +110,7 @@ class UsersController extends Controller
//Username, email, and password need to be handled specially because the need to respect config values on an edit. //Username, email, and password need to be handled specially because the need to respect config values on an edit.
$user->email = e($request->input('email')); $user->email = e($request->input('email'));
$user->username = e($request->input('username')); $user->username = e($request->input('username'));
if ($request->has('password')) { if ($request->filled('password')) {
$user->password = bcrypt($request->input('password')); $user->password = bcrypt($request->input('password'));
} }
$user->first_name = $request->input('first_name'); $user->first_name = $request->input('first_name');
@ -141,13 +141,13 @@ class UsersController extends Controller
if ($user->save()) { if ($user->save()) {
if ($request->has('groups')) { if ($request->filled('groups')) {
$user->groups()->sync($request->input('groups')); $user->groups()->sync($request->input('groups'));
} else { } else {
$user->groups()->sync(array()); $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 // Send the credentials through email
$data = array(); $data = array();
$data['email'] = e($request->input('email')); $data['email'] = e($request->input('email'));
@ -258,13 +258,13 @@ class UsersController extends Controller
// Only save groups if the user is a super user // Only save groups if the user is a super user
if (Auth::user()->isSuperUser()) { if (Auth::user()->isSuperUser()) {
if ($request->has('groups')) { if ($request->filled('groups')) {
$user->groups()->sync($request->input('groups')); $user->groups()->sync($request->input('groups'));
} }
} }
if ($request->has('username')) { if ($request->filled('username')) {
$user->username = $request->input('username'); $user->username = $request->input('username');
} }
$user->email = $request->input('email'); $user->email = $request->input('email');
@ -298,7 +298,7 @@ class UsersController extends Controller
->update(['location_id' => $request->input('location_id', null)]); ->update(['location_id' => $request->input('location_id', null)]);
// Do we want to update the user password? // Do we want to update the user password?
if ($request->has('password')) { if ($request->filled('password')) {
$user->password = bcrypt($request->input('password')); $user->password = bcrypt($request->input('password'));
} }

View file

@ -258,7 +258,7 @@ class ViewAssetsController extends Controller
return redirect()->to('account/view-assets')->with('error', trans('admin/users/message.error.incorrect_user_accepted')); 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'; $path = config('app.private_uploads').'/signatures';
$sig_filename = "siglog-".$findlog->id.'-'.date('Y-m-d-his').".png"; $sig_filename = "siglog-".$findlog->id.'-'.date('Y-m-d-his').".png";
$data_uri = e($request->get('signature_output')); $data_uri = e($request->get('signature_output'));