Use $request->input over Request::get()

This commit is contained in:
snipe 2019-12-11 11:09:54 -08:00
parent a5b180a9c6
commit c31e150935
17 changed files with 64 additions and 65 deletions

View file

@ -64,12 +64,12 @@ class AccessoryCheckoutController extends Controller
$this->authorize('checkout', $accessory);
if (!$user = User::find(Request::get('assigned_to'))) {
if (!$user = User::find($request->input('assigned_to'))) {
return redirect()->route('checkout/accessory', $accessory->id)->with('error', trans('admin/accessories/message.checkout.user_does_not_exist'));
}
// Update the accessory data
$accessory->assigned_to = e(Request::get('assigned_to'));
$accessory->assigned_to = e($request->input('assigned_to'));
$accessory->users()->attach($accessory->id, [
'accessory_id' => $accessory->id,

View file

@ -62,8 +62,8 @@ class AssetMaintenancesController extends Controller
'asset_name',
'user_id'
];
$order = Request::get('order') === 'asc' ? 'asc' : 'desc';
$sort = in_array(Request::get('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
$sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
switch ($sort) {
case 'user_id':

View file

@ -738,12 +738,12 @@ class AssetsController extends Controller
$asset->location_id = $request->input('location_id');
}
if (Request::has('status_id')) {
$asset->status_id = Request::get('status_id');
if ($request->has('status_id')) {
$asset->status_id = $request->input('status_id');
}
if ($asset->save()) {
$asset->logCheckin($target, e(request('note')));
$asset->logCheckin($target, e($request->input('note')));
return response()->json(Helper::formatStandardApiResponse('success', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkin.success')));
}

View file

@ -306,7 +306,7 @@ class AssetModelsController extends Controller
public function postBulkEdit(Request $request)
{
$models_raw_array = Request::get('ids');
$models_raw_array = $request->input('ids');
// Make sure some IDs have been selected
if ((is_array($models_raw_array)) && (count($models_raw_array) > 0)) {
@ -355,7 +355,7 @@ class AssetModelsController extends Controller
public function postBulkEditSave(Request $request)
{
$models_raw_array = Request::get('ids');
$models_raw_array = $request->input('ids');
$update_array = array();
@ -396,7 +396,7 @@ class AssetModelsController extends Controller
*/
public function postBulkDelete(Request $request)
{
$models_raw_array = Request::get('ids');
$models_raw_array = $request->input('ids');
if ((is_array($models_raw_array)) && (count($models_raw_array) > 0)) {

View file

@ -20,7 +20,7 @@ class BulkAssetModelsController extends Controller
*/
public function edit(Request $request)
{
$models_raw_array = Request::get('ids');
$models_raw_array = $request->input('ids');
// Make sure some IDs have been selected
if ((is_array($models_raw_array)) && (count($models_raw_array) > 0)) {
@ -64,7 +64,7 @@ class BulkAssetModelsController extends Controller
public function update(Request $request)
{
$models_raw_array = Request::get('ids');
$models_raw_array = $request->input('ids');
$update_array = array();
if (($request->filled('manufacturer_id') && ($request->input('manufacturer_id')!='NC'))) {
@ -101,9 +101,9 @@ class BulkAssetModelsController extends Controller
* @since [v1.0]
* @return Redirect
*/
public function destroy()
public function destroy(Request $request)
{
$models_raw_array = Request::get('ids');
$models_raw_array = $request->input('ids');
if ((is_array($models_raw_array)) && (count($models_raw_array) > 0)) {

View file

@ -69,7 +69,7 @@ class ComponentCheckoutController extends Controller
}
$admin_user = Auth::user();
$asset_id = e(Request::get('asset_id'));
$asset_id = e($request->input('asset_id'));
// Check if the user exists
if (is_null($asset = Asset::find($asset_id))) {
@ -84,7 +84,7 @@ class ComponentCheckoutController extends Controller
'component_id' => $component->id,
'user_id' => $admin_user->id,
'created_at' => date('Y-m-d H:i:s'),
'assigned_qty' => Request::get('assigned_qty'),
'assigned_qty' => $request->input('assigned_qty'),
'asset_id' => $asset_id
]);

View file

@ -125,16 +125,16 @@ class ComponentsController extends Controller
$this->authorize('update', $component);
// Update the component data
$component->name = Request::get('name');
$component->category_id = Request::get('category_id');
$component->location_id = Request::get('location_id');
$component->company_id = Company::getIdForCurrentUser(Request::get('company_id'));
$component->order_number = Request::get('order_number');
$component->min_amt = Request::get('min_amt');
$component->serial = Request::get('serial');
$component->purchase_date = Request::get('purchase_date');
$component->name = $request->input('name');
$component->category_id = $request->input('category_id');
$component->location_id = $request->input('location_id');
$component->company_id = Company::getIdForCurrentUser($request->input('company_id'));
$component->order_number = $request->input('order_number');
$component->min_amt = $request->input('min_amt');
$component->serial = $request->input('serial');
$component->purchase_date = $request->input('purchase_date');
$component->purchase_cost = request('purchase_cost');
$component->qty = Request::get('qty');
$component->qty = $request->input('qty');
$component = $request->handleImages($component);

View file

@ -51,7 +51,7 @@ class ConsumableCheckoutController extends Controller
$this->authorize('checkout', $consumable);
$admin_user = Auth::user();
$assigned_to = e(Request::get('assigned_to'));
$assigned_to = e($request->input('assigned_to'));
// Check if the user exists
if (is_null($user = User::find($assigned_to))) {
@ -60,12 +60,12 @@ class ConsumableCheckoutController extends Controller
}
// Update the consumable data
$consumable->assigned_to = e(Request::get('assigned_to'));
$consumable->assigned_to = e($request->input('assigned_to'));
$consumable->users()->attach($consumable->id, [
'consumable_id' => $consumable->id,
'user_id' => $admin_user->id,
'assigned_to' => e(Request::get('assigned_to'))
'assigned_to' => e($request->input('assigned_to'))
]);
event(new CheckoutableCheckedOut($consumable, $user, Auth::user(), $request->input('note')));

View file

@ -141,8 +141,8 @@ class ConsumablesController extends Controller
$consumable->model_number = $request->input('model_number');
$consumable->item_no = $request->input('item_no');
$consumable->purchase_date = $request->input('purchase_date');
$consumable->purchase_cost = Helper::ParseFloat(Request::get('purchase_cost'));
$consumable->qty = Helper::ParseFloat(Request::get('qty'));
$consumable->purchase_cost = Helper::ParseFloat($request->input('purchase_cost'));
$consumable->qty = Helper::ParseFloat($request->input('qty'));
$consumable = $request->handleImages($consumable);

View file

@ -188,7 +188,7 @@ class CustomFieldsetsController extends Controller
}
}
$results = $set->fields()->attach(Request::get('field_id'), ["required" => ($request->input('required') == "on"),"order" => $request->input('order', 1)]);
$results = $set->fields()->attach($request->input('field_id'), ["required" => ($request->input('required') == "on"),"order" => $request->input('order', 1)]);
return redirect()->route("fieldsets.show", [$id])->with("success", trans('admin/custom_fields/message.field.create.assoc_success'));
}

View file

@ -57,12 +57,12 @@ class GroupsController extends Controller
* @since [v1.0]
* @return \Illuminate\Http\RedirectResponse
*/
public function store()
public function store(Request $request)
{
// create a new group instance
$group = new Group();
$group->name = e(Request::get('name'));
$group->permissions = json_encode(Request::get('permission'));
$group->name = $request->input('name');
$group->permissions = json_encode($request->input('permission'));
if ($group->save()) {
return redirect()->route("groups.index")->with('success', trans('admin/groups/message.success.create'));
@ -102,13 +102,13 @@ class GroupsController extends Controller
* @since [v1.0]
* @return \Illuminate\Http\RedirectResponse
*/
public function update($id = null)
public function update(Request $request, $id = null)
{
if (!$group = Group::find($id)) {
return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', compact('id')));
}
$group->name = e(Request::get('name'));
$group->permissions = json_encode(Request::get('permission'));
$group->name = $request->input('name');
$group->permissions = json_encode($request->input('permission'));
if (!config('app.lock_passwords')) {
if ($group->save()) {

View file

@ -470,7 +470,7 @@ class ReportsController extends Controller
foreach ($customfields as $customfield) {
if (e(Request::get($customfield->db_column_name())) == '1') {
if (e($request->input($customfield->db_column_name())) == '1') {
$header[] = $customfield->name;
}
}

View file

@ -184,7 +184,7 @@ class SettingsController extends Controller
Auth::login($user, true);
$settings->save();
if ('1' == Request::get('email_creds')) {
if ('1' == $request->input('email_creds')) {
$data = [];
$data['email'] = $user->email;
$data['username'] = $user->username;
@ -345,7 +345,7 @@ class SettingsController extends Controller
$setting->depreciation_method = $request->input('depreciation_method');
if ('' != Request::get('per_page')) {
if ($request->missing('per_page')) {
$setting->per_page = $request->input('per_page');
} else {
$setting->per_page = 200;
@ -1134,10 +1134,10 @@ class SettingsController extends Controller
*
* @return View
*/
public function postPurge()
public function postPurge(Request $request)
{
if (! config('app.lock_passwords')) {
if ('DELETE' == Request::get('confirm_purge')) {
if ('DELETE' == $request->input('confirm_purge')) {
// Run a backup immediately before processing
Artisan::call('backup:run');
Artisan::call('snipeit:purge', ['--force' => 'true', '--no-interaction' => true]);

View file

@ -3,9 +3,8 @@ namespace App\Http\Controllers;
use App\Helpers\Helper;
use App\Models\Statuslabel;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use Illuminate\Http\Request;
/**
* This controller handles all actions related to Status Labels for
@ -71,22 +70,22 @@ class StatuslabelsController extends Controller
// create a new model instance
$statusLabel = new Statuslabel();
if (!$request->filled('statuslabel_types')) {
if ($request->missing('statuslabel_types')) {
return redirect()->back()->withInput()->withErrors(['statuslabel_types' => trans('validation.statuslabel_type')]);
}
$statusType = Statuslabel::getStatuslabelTypesForDB($request->input('statuslabel_types'));
// Save the Statuslabel data
$statusLabel->name = Request::get('name');
$statusLabel->name = $request->input('name');
$statusLabel->user_id = Auth::id();
$statusLabel->notes = Request::get('notes');
$statusLabel->notes = $request->input('notes');
$statusLabel->deployable = $statusType['deployable'];
$statusLabel->pending = $statusType['pending'];
$statusLabel->archived = $statusType['archived'];
$statusLabel->color = Request::get('color');
$statusLabel->show_in_nav = Request::get('show_in_nav', 0);
$statusLabel->default_label = Request::get('default_label', 0);
$statusLabel->color = $request->input('color');
$statusLabel->show_in_nav = $request->input('show_in_nav', 0);
$statusLabel->default_label = $request->input('default_label', 0);
if ($statusLabel->save()) {
@ -142,15 +141,15 @@ class StatuslabelsController extends Controller
// Update the Statuslabel data
$statustype = Statuslabel::getStatuslabelTypesForDB(Request::get('statuslabel_types'));
$statuslabel->name = Request::get('name');
$statuslabel->notes = Request::get('notes');
$statustype = Statuslabel::getStatuslabelTypesForDB($request->input('statuslabel_types'));
$statuslabel->name = $request->input('name');
$statuslabel->notes = $request->input('notes');
$statuslabel->deployable = $statustype['deployable'];
$statuslabel->pending = $statustype['pending'];
$statuslabel->archived = $statustype['archived'];
$statuslabel->color = Request::get('color');
$statuslabel->show_in_nav = Request::get('show_in_nav', 0);
$statuslabel->default_label = Request::get('default_label', 0);
$statuslabel->color = $request->input('color');
$statuslabel->show_in_nav = $request->input('show_in_nav', 0);
$statuslabel->default_label = $request->input('default_label', 0);
// Was the asset created?

View file

@ -45,7 +45,7 @@ class UserFilesController extends Controller
$logAction->item_id = $user->id;
$logAction->item_type = User::class;
$logAction->user_id = Auth::id();
$logAction->note = e(Request::get('notes'));
$logAction->note = $request->input('notes');
$logAction->target_id = null;
$logAction->created_at = date("Y-m-d H:i:s");
$logAction->filename = $filename;

View file

@ -461,12 +461,12 @@ class UsersController extends Controller
* @return \Illuminate\Contracts\View\View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/
public function getClone($id = null)
public function getClone(Request $request, $id = null)
{
$this->authorize('create', User::class);
// We need to reverse the UI specific logic for our
// permissions here before we update the user.
$permissions = Request::get('permissions', array());
$permissions = $request->input('permissions', array());
app('request')->request->set('permissions', $permissions);

View file

@ -70,7 +70,7 @@ class ViewAssetsController extends Controller
public function getRequestItem($itemType, $itemId = null)
public function getRequestItem(Request $request, $itemType, $itemId = null)
{
$item = null;
$fullItemType = 'App\\Models\\' . studly_case($itemType);
@ -94,7 +94,7 @@ class ViewAssetsController extends Controller
$logaction->target_id = $data['user_id'] = Auth::user()->id;
$logaction->target_type = User::class;
$data['item_quantity'] = Request::has('request-quantity') ? e(Request::get('request-quantity')) : 1;
$data['item_quantity'] = $request->has('request-quantity') ? e($request->input('request-quantity')) : 1;
$data['requested_by'] = $user->present()->fullName();
$data['item'] = $item;
$data['item_type'] = $itemType;
@ -252,7 +252,7 @@ class ViewAssetsController extends Controller
return redirect()->to('account/view-assets')->with('error', trans('admin/users/message.error.asset_already_accepted'));
}
if (!Request::has('asset_acceptance')) {
if ($request->missing('asset_acceptance')) {
return redirect()->back()->with('error', trans('admin/users/message.error.accept_or_decline'));
}
@ -274,7 +274,7 @@ class ViewAssetsController extends Controller
$logaction = new Actionlog();
if (Request::get('asset_acceptance')=='accepted') {
if ($request->input('asset_acceptance')=='accepted') {
$logaction_msg = 'accepted';
$accepted="accepted";
$return_msg = trans('admin/users/message.accepted');
@ -288,7 +288,7 @@ class ViewAssetsController extends Controller
// Asset
if (($findlog->item_id!='') && ($findlog->item_type==Asset::class)) {
if (Request::get('asset_acceptance')!='accepted') {
if ($request->input('asset_acceptance')!='accepted') {
DB::table('assets')
->where('id', $findlog->item_id)
->update(array('assigned_to' => null));
@ -297,7 +297,7 @@ class ViewAssetsController extends Controller
$logaction->target_id = $findlog->target_id;
$logaction->target_type = User::class;
$logaction->note = e(Request::get('note'));
$logaction->note = e($request->input('note'));
$logaction->updated_at = date("Y-m-d H:i:s");