Skip to content

Commit

Permalink
Use $request instead of Input::
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Dec 15, 2016
1 parent eb9207d commit 1ab4144
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions app/Http/Controllers/DepreciationsController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
namespace App\Http\Controllers;

use Input;
use Lang;
use App\Models\Depreciation;
use Redirect;
Expand All @@ -10,6 +9,7 @@
use Str;
use View;
use Auth;
use Illuminate\Http\Request;

/**
* This controller handles all actions related to Depreciations for
Expand Down Expand Up @@ -58,7 +58,7 @@ public function getCreate()
* @since [v1.0]
* @return Redirect
*/
public function postCreate()
public function postCreate(Request $request)
{

// get the POST data
Expand All @@ -68,8 +68,8 @@ public function postCreate()
$depreciation = new Depreciation();

// Depreciation data
$depreciation->name = e(Input::get('name'));
$depreciation->months = e(Input::get('months'));
$depreciation->name = e($request->input('name'));
$depreciation->months = e($request->input('months'));
$depreciation->user_id = Auth::user()->id;

// Was the asset created?
Expand Down Expand Up @@ -112,7 +112,7 @@ public function getEdit($depreciationId = null)
* @since [v1.0]
* @return Redirect
*/
public function postEdit($depreciationId = null)
public function postEdit(Request $request, $depreciationId = null)
{
// Check if the depreciation exists
if (is_null($depreciation = Depreciation::find($depreciationId))) {
Expand All @@ -121,8 +121,8 @@ public function postEdit($depreciationId = null)
}

// Depreciation data
$depreciation->name = e(Input::get('name'));
$depreciation->months = e(Input::get('months'));
$depreciation->name = e($request->input('name'));
$depreciation->months = e($request->input('months'));

// Was the asset created?
if ($depreciation->save()) {
Expand Down Expand Up @@ -176,29 +176,29 @@ public function getDelete($depreciationId)
* @since [v1.2]
* @return String JSON
*/
public function getDatatable()
public function getDatatable(Request $request)
{
$depreciations = Depreciation::select(array('id','name','months'));

if (Input::has('search')) {
$depreciations = $depreciations->TextSearch(e(Input::get('search')));
if ($request->has('search')) {
$depreciations = $depreciations->TextSearch(e($request->input('search')));
}

if (Input::has('offset')) {
$offset = e(Input::get('offset'));
if ($request->has('offset')) {
$offset = e($request->input('offset'));
} else {
$offset = 0;
}

if (Input::has('limit')) {
$limit = e(Input::get('limit'));
if ($request->has('limit')) {
$limit = e($request->input('limit'));
} else {
$limit = 50;
}

$allowed_columns = ['id','name','months'];
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
$sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';

$depreciations->orderBy($sort, $order);

Expand Down

0 comments on commit 1ab4144

Please sign in to comment.