Change ->has() to ->filled()

This commit is contained in:
snipe 2019-05-23 17:39:50 -07:00
parent 8db2470ac4
commit 2d036c64e9
29 changed files with 148 additions and 148 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 = (($assets) && (request('offset') > $assets->count())) ? 0 : request('offset', 0); $offset = (($assets) && (request('offset') > $assets->count())) ? 0 : request('offset', 0);
$limit = $request->input('limit', 50); $limit = $request->input('limit', 50);
@ -216,7 +216,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")
@ -235,7 +235,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'));
} }
@ -371,11 +371,11 @@ class AssetsController extends Controller
'assets.status_id' 'assets.status_id'
])->with('model', 'assetstatus', 'assignedTo')->NotArchived(),'company_id', 'assets'); ])->with('model', 'assetstatus', 'assignedTo')->NotArchived(),'company_id', 'assets');
if ($request->has('assetStatusType') && $request->input('assetStatusType') === 'RTD') { if ($request->filled('assetStatusType') && $request->input('assetStatusType') === 'RTD') {
$assets = $assets->RTD(); $assets = $assets->RTD();
} }
if ($request->has('search')) { if ($request->filled('search')) {
$assets = $assets->AssignedSearch($request->input('search')); $assets = $assets->AssignedSearch($request->input('search'));
} }
@ -493,11 +493,11 @@ class AssetsController extends Controller
$asset->fill($request->all()); $asset->fill($request->all());
($request->has('model_id')) ? ($request->filled('model_id')) ?
$asset->model()->associate(AssetModel::find($request->get('model_id'))) : null; $asset->model()->associate(AssetModel::find($request->get('model_id'))) : null;
($request->has('company_id')) ? ($request->filled('company_id')) ?
$asset->company_id = Company::getIdForCurrentUser($request->get('company_id')) : null; $asset->company_id = Company::getIdForCurrentUser($request->get('company_id')) : null;
($request->has('rtd_location_id')) ? ($request->filled('rtd_location_id')) ?
$asset->location_id = $request->get('rtd_location_id') : null; $asset->location_id = $request->get('rtd_location_id') : null;
// Update custom fields // Update custom fields
@ -518,11 +518,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 +677,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,19 +27,19 @@ 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('category_id')) { if ($request->filled('category_id')) {
$consumables->where('category_id','=',$request->input('category_id')); $consumables->where('category_id','=',$request->input('category_id'));
} }
if ($request->has('manufacturer_id')) { if ($request->filled('manufacturer_id')) {
$consumables->where('manufacturer_id','=',$request->input('manufacturer_id')); $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 freeSeats_count')); $licenses = Company::scopeCompanyables(License::with('company', 'manufacturer', 'freeSeats', 'supplier','category')->withCount('freeSeats as freeSeats_count'));
if ($request->has('company_id')) { if ($request->filled('company_id')) {
$licenses->where('company_id','=',$request->input('company_id')); $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'));
} }
@ -192,7 +192,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

@ -62,27 +62,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'));
} }
@ -148,7 +148,7 @@ class UsersController extends Controller
$users = Company::scopeCompanyables($users); $users = Company::scopeCompanyables($users);
if ($request->has('search')) { if ($request->filled('search')) {
$users = $users->SimpleNameSearch($request->get('search')) $users = $users->SimpleNameSearch($request->get('search'))
->orWhere('username', 'LIKE', '%'.$request->get('search').'%') ->orWhere('username', 'LIKE', '%'.$request->get('search').'%')
->orWhere('employee_num', 'LIKE', '%'.$request->get('search').'%'); ->orWhere('employee_num', 'LIKE', '%'.$request->get('search').'%');
@ -201,7 +201,7 @@ class UsersController extends Controller
$user->password = bcrypt($request->get('password', $tmp_pass)); $user->password = bcrypt($request->get('password', $tmp_pass));
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());
@ -247,7 +247,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'));
} }
@ -257,7 +257,7 @@ 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());
@ -340,7 +340,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

@ -67,13 +67,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

@ -71,12 +71,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

@ -420,10 +420,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;
@ -96,7 +96,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);
} }
@ -143,7 +143,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:
@ -313,7 +313,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=='') {
@ -321,7 +321,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 = '';
@ -343,7 +343,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];

View file

@ -275,7 +275,7 @@ class LoginController extends Controller
return redirect()->route('login')->with('error', trans('auth/general.login_prompt')); return redirect()->route('login')->with('error', trans('auth/general.login_prompt'));
} }
if (!$request->has('two_factor_secret')) { if (!$request->filled('two_factor_secret')) {
return redirect()->route('two-factor')->with('error', trans('auth/message.two_factor.code_required')); return redirect()->route('two-factor')->with('error', trans('auth/message.two_factor.code_required'));
} }

View file

@ -26,13 +26,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')
@ -68,22 +68,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 = [];
@ -96,20 +96,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');
} }
} }
@ -155,7 +155,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');
@ -206,13 +206,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

@ -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

@ -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'));
} }
@ -495,7 +495,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'));
} }
@ -794,31 +794,31 @@ class SettingsController extends Controller
if ($request->has('labels_display_name')) { if ($request->filled('labels_display_name')) {
$setting->labels_display_name = 1; $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

@ -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')]);
} }
@ -141,7 +141,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

@ -107,7 +107,7 @@ class UsersController extends Controller
//Username, email, and password need to be handled specially because the need to respect config values on an edit. //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');
} }
@ -139,13 +139,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'));
@ -263,7 +263,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');
@ -297,7 +297,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'));
} }
@ -390,7 +390,7 @@ class UsersController 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();
$user_raw_array = array_keys(Input::get('ids')); $user_raw_array = array_keys(Input::get('ids'));
$users = User::whereIn('id', $user_raw_array)->with('groups', 'assets', 'licenses', 'accessories')->get(); $users = User::whereIn('id', $user_raw_array)->with('groups', 'assets', 'licenses', 'accessories')->get();
@ -416,28 +416,28 @@ class UsersController extends Controller
{ {
$this->authorize('update', User::class); $this->authorize('update', User::class);
if (($request->has('ids')) && (count($request->input('ids')) > 0)) { if (($request->filled('ids')) && (count($request->input('ids')) > 0)) {
$user_raw_array = $request->input('ids'); $user_raw_array = $request->input('ids');
$update_array = array(); $update_array = array();
$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->has('manager_id')) { if ($request->filled('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.
@ -448,7 +448,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');
} }
@ -458,7 +458,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'));
} }
@ -490,9 +490,9 @@ class UsersController 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');
} elseif ((!$request->has('status_id')) || ($request->input('status_id')=='')) { } elseif ((!$request->filled('status_id')) || ($request->input('status_id')=='')) {
return redirect()->route('users.index')->with('error', 'No status selected'); return redirect()->route('users.index')->with('error', 'No status selected');
} else { } else {

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'));