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

This commit is contained in:
snipe 2018-04-11 17:47:02 -07:00 committed by Daniel Meltzer
parent d5a740358e
commit bb5cb64ba9
No known key found for this signature in database
GPG key ID: 91C5C7B09A5B1CA0
27 changed files with 235 additions and 237 deletions

View file

@ -86,7 +86,7 @@ class AccessoriesController extends Controller
$accessory->user_id = Auth::user()->id; $accessory->user_id = Auth::user()->id;
$accessory->supplier_id = request('supplier_id'); $accessory->supplier_id = request('supplier_id');
if ($request->hasFile('image')) { if ($request->filledFile('image')) {
if (!config('app.lock_passwords')) { if (!config('app.lock_passwords')) {
$image = $request->file('image'); $image = $request->file('image');
@ -165,7 +165,7 @@ class AccessoriesController extends Controller
$accessory->qty = request('qty'); $accessory->qty = request('qty');
$accessory->supplier_id = request('supplier_id'); $accessory->supplier_id = request('supplier_id');
if ($request->hasFile('image')) { if ($request->filledFile('image')) {
if (!config('app.lock_passwords')) { if (!config('app.lock_passwords')) {

View file

@ -26,23 +26,23 @@ class AccessoriesController extends Controller
$accessories = Accessory::whereNull('accessories.deleted_at')->with('category', 'company', 'manufacturer', 'users', 'location'); $accessories = Accessory::whereNull('accessories.deleted_at')->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,8 +84,9 @@ class AssetsController extends Controller
$filter = array(); $filter = array();
if ($request->has('filter')) {
$filter = json_decode($request->input('filter'), true); if ($request->filled('filter')) {
$filter = json_decode($request->input('filter'));
} }
$all_custom_fields = CustomField::all(); //used as a 'cache' of custom fields throughout this page load $all_custom_fields = CustomField::all(); //used as a 'cache' of custom fields throughout this page load
@ -101,7 +102,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 +110,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 +202,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 +221,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'));
} }
@ -359,7 +360,7 @@ class AssetsController extends Controller
$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'));
} }
@ -468,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()));
} }
} }
@ -518,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;
} }
@ -677,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', 'accessories', 'consumables', 'components','licenses'); ->withCount('assets', 'accessories', 'consumables', 'components','licenses');
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','licenses','accessories','consumables','components','users'); $companies = Company::withCount('assets','licenses','accessories','consumables','components','users');
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,15 +27,15 @@ class ComponentsController extends Controller
$components = Company::scopeCompanyables(Component::select('components.*')->whereNull('components.deleted_at') $components = Company::scopeCompanyables(Component::select('components.*')->whereNull('components.deleted_at')
->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'));
} }

View file

@ -28,15 +28,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'); ])->with('users')->with('location')->with('manager')->with('company')->withCount('users');
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'); $groups = Group::select('id','name','permissions','created_at','updated_at')->withCount('users');
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')); $licenses = Company::scopeCompanyables(License::with('company', 'manufacturer', 'freeSeats', 'supplier','category')->withCount('freeSeats'));
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_i')) { if ($request->filled('category_id')) {
$licenses->where('category_i','=',$request->input('category_i')); $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') ->withCount('assets')
->withCount('users'); ->withCount('users');
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,21 +22,21 @@ 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');
} }

View file

@ -26,7 +26,7 @@ class StatuslabelsController extends Controller
$statuslabels = Statuslabel::withCount('assets'); $statuslabels = Statuslabel::withCount('assets');
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')->withCount('licenses')->withCount('accessories')->whereNull('deleted_at'); )->withCount('assets')->withCount('licenses')->withCount('accessories')->whereNull('deleted_at');
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

@ -467,10 +467,10 @@ class AssetModelsController extends Controller
$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

@ -71,7 +71,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;
@ -118,7 +118,7 @@ class AssetsController extends Controller
->with('category', Helper::categoryList('asset')) //handled in modal now? ->with('category', Helper::categoryList('asset')) //handled in modal now?
->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);
} }
@ -165,7 +165,7 @@ class AssetsController extends Controller
} }
// Create the image (if one was chosen.) // Create the image (if one was chosen.)
if ($request->has('image')) { if ($request->filled('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:
@ -293,22 +293,20 @@ 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=='') {
$asset->location_id = $request->input('rtd_location_id', null); $asset->location_id = $request->input('rtd_location_id', null);
} }
if ($request->filled('image_delete')) {
if ($request->has('image_delete')) {
try { try {
unlink(public_path().'/uploads/assets/'.$asset->image); unlink(public_path().'/uploads/assets/'.$asset->image);
$asset->image = ''; $asset->image = '';
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::error($e); \Log::error($e);
} }
} }
@ -950,7 +948,7 @@ class AssetsController extends Controller
$destinationPath = config('app.private_uploads').'/assets'; $destinationPath = config('app.private_uploads').'/assets';
if ($request->hasFile('assetfile')) { if ($request->filledFile('assetfile')) {
foreach ($request->file('assetfile') as $file) { foreach ($request->file('assetfile') as $file) {
$extension = $file->getClientOriginalExtension(); $extension = $file->getClientOriginalExtension();
$filename = 'hardware-'.$asset->id.'-'.str_random(8).'-'.str_slug(basename($file->getClientOriginalName(), '.'.$extension)).'.'.$extension; $filename = 'hardware-'.$asset->id.'-'.str_random(8).'-'.str_slug(basename($file->getClientOriginalName(), '.'.$extension)).'.'.$extension;
@ -1055,7 +1053,7 @@ class AssetsController 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');
} }
@ -1065,7 +1063,7 @@ class AssetsController extends Controller
} }
if ($request->has('bulk_actions')) { if ($request->filled('bulk_actions')) {
if ($request->input('bulk_actions')=='labels') { if ($request->input('bulk_actions')=='labels') {
$count = 0; $count = 0;
return view('hardware/labels') return view('hardware/labels')
@ -1106,62 +1104,62 @@ class AssetsController 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)) {
$assets = $request->input('ids'); $assets = $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 $key => $value) { foreach ($assets as $key => $value) {
$update_array = array(); $update_array = array();
if ($request->has('purchase_date')) { if ($request->filled('purchase_date')) {
$update_array['purchase_date'] = $request->input('purchase_date'); $update_array['purchase_date'] = $request->input('purchase_date');
} }
if ($request->has('purchase_cost')) { if ($request->filled('purchase_cost')) {
$update_array['purchase_cost'] = Helper::ParseFloat($request->input('purchase_cost')); $update_array['purchase_cost'] = Helper::ParseFloat($request->input('purchase_cost'));
} }
if ($request->has('supplier_id')) { if ($request->filled('supplier_id')) {
$update_array['supplier_id'] = $request->input('supplier_id'); $update_array['supplier_id'] = $request->input('supplier_id');
} }
if ($request->has('model_id')) { if ($request->filled('model_id')) {
$update_array['model_id'] = $request->input('model_id'); $update_array['model_id'] = $request->input('model_id');
} }
if ($request->has('company_id')) { if ($request->filled('company_id')) {
if ($request->input('company_id')=="clear") { if ($request->input('company_id')=="clear") {
$update_array['company_id'] = null; $update_array['company_id'] = null;
} else { } else {
$update_array['company_id'] = $request->input('company_id'); $update_array['company_id'] = $request->input('company_id');
} }
} }
if ($request->has('order_number')) { if ($request->filled('order_number')) {
$update_array['order_number'] = $request->input('order_number'); $update_array['order_number'] = $request->input('order_number');
} }
if ($request->has('warranty_months')) { if ($request->filled('warranty_months')) {
$update_array['warranty_months'] = $request->input('warranty_months'); $update_array['warranty_months'] = $request->input('warranty_months');
} }
if ($request->has('rtd_location_id')) { if ($request->filled('rtd_location_id')) {
$update_array['rtd_location_id'] = $request->input('rtd_location_id'); $update_array['rtd_location_id'] = $request->input('rtd_location_id');
if (($request->has('update_real_loc')) if (($request->filled('update_real_loc'))
&& (($request->input('update_real_loc')) == '1')) && (($request->input('update_real_loc')) == '1'))
{ {
$update_array['location_id'] = $request->input('rtd_location_id'); $update_array['location_id'] = $request->input('rtd_location_id');
} }
} }
if ($request->has('status_id')) { if ($request->filled('status_id')) {
$update_array['status_id'] = $request->input('status_id'); $update_array['status_id'] = $request->input('status_id');
} }
if ($request->has('requestable')) { if ($request->filled('requestable')) {
$update_array['requestable'] = $request->input('requestable'); $update_array['requestable'] = $request->input('requestable');
} }

View file

@ -30,7 +30,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);
@ -51,7 +51,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 ($request->file('image')) { if ($request->file('image')) {
$image = $request->file('image'); $image = $request->file('image');
@ -162,7 +162,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);
$old_image = $department->image; $old_image = $department->image;

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,48 +471,48 @@ 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')]);
} }
@ -525,61 +525,62 @@ 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 +589,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 +603,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 +617,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 +626,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 {
@ -642,55 +643,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'));
} }
@ -417,7 +417,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');
@ -494,7 +494,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'));
} }

View file

@ -78,7 +78,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')]);
} }
@ -111,7 +111,7 @@ class StatuslabelsController extends Controller
{ {
$this->authorize('create', Statuslabel::class); $this->authorize('create', Statuslabel::class);
$statuslabel = new Statuslabel(); $statuslabel = new Statuslabel();
if (!$request->has('statuslabel_types')) { if (!$request->filled('statuslabel_types')) {
return JsonResponse::create(["error" => trans('validation.statuslabel_type')], 500); return JsonResponse::create(["error" => trans('validation.statuslabel_type')], 500);
} }
$statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('statuslabel_types')); $statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('statuslabel_types'));
@ -171,7 +171,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

@ -103,7 +103,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 = $data['email'] = e($request->input('email')); $user->email = $data['email'] = e($request->input('email'));
$user->username = $data['username'] = e($request->input('username')); $user->username = $data['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'));
$data['password'] = $request->input('password'); $data['password'] = $request->input('password');
} }
@ -135,13 +135,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'));
@ -184,7 +184,7 @@ class UsersController extends Controller
$user->username = $request->input('username'); $user->username = $request->input('username');
$user->email = $request->input('email'); $user->email = $request->input('email');
$user->department_id = $request->input('department_id', null); $user->department_id = $request->input('department_id', null);
if ($request->has('password')) { if ($request->filled('password')) {
$user->password = bcrypt($request->input('password')); $user->password = bcrypt($request->input('password'));
} }
$user->activated = true; $user->activated = true;
@ -306,7 +306,7 @@ 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'));
} else { } else {
$user->groups()->sync(array()); $user->groups()->sync(array());
@ -314,7 +314,7 @@ class UsersController extends Controller
} }
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');
@ -346,7 +346,7 @@ class UsersController extends Controller
->where('assigned_to', $user->id)->update(['location_id' => $request->input('location_id', null)]); ->where('assigned_to', $user->id)->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'));
} }
@ -472,22 +472,20 @@ class UsersController extends Controller
$manager_conflict = false; $manager_conflict = false;
$users = User::whereIn('id', $user_raw_array)->where('id', '!=', Auth::user()->id)->get(); $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'); $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'); $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'); $update_array['company_id'] = $request->input('company_id');
} }
if ($request->has('locale')) { if ($request->filled('locale')) {
$update_array['locale'] = $request->input('locale'); $update_array['locale'] = $request->input('locale');
} }
if ($request->filled('manager_id')) {
if ($request->has('manager_id')) {
// Do not allow a manager update if the selected manager is one of the users being // Do not allow a manager update if the selected manager is one of the users being
// edited. // edited.
if (!array_key_exists($request->input('manager_id'), $user_raw_array)) { if (!array_key_exists($request->input('manager_id'), $user_raw_array)) {
@ -497,7 +495,7 @@ class UsersController extends Controller
} }
} }
if ($request->has('activated')) { if ($request->filled('activated')) {
$update_array['activated'] = $request->input('activated'); $update_array['activated'] = $request->input('activated');
} }
@ -507,7 +505,7 @@ class UsersController extends Controller
} }
// 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'));
} }

View file

@ -269,7 +269,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'));