Skip to content

Commit

Permalink
replace Input for request(), to guarantee a wider support
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Selge committed Aug 13, 2016
1 parent 9e2942d commit c2643f0
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Database\Eloquent\Model;
use RickTap\Qriteria\NestedFilter;
use Input;

class Query
{
Expand Down Expand Up @@ -61,6 +60,8 @@ class Query
*/
protected $includeFieldSelects = array();

protected $request;

/**
* Create a new Request Criteria Query instance.
*
Expand All @@ -73,6 +74,9 @@ public function __construct(Model $model, callable $queryCall = null)
$this->model = $model;
$this->query = $model->query();

// get the request from the app
$this->request = request();

$this->prepareQueryIfTrait();

if (is_callable($queryCall)) {
Expand Down Expand Up @@ -131,7 +135,7 @@ public function paginate()
{
return $this->query
->paginate($this->limit)
->appends(Input::except('page'));
->appends($this->request->except('page'));
}

/**
Expand All @@ -154,7 +158,7 @@ public function unlimited()
*/
protected function grabLimit()
{
$this->limit = Input::get('limit', static::$defaultLimit);
$this->limit = $this->request->input('limit', static::$defaultLimit);
return $this;
}

Expand All @@ -166,7 +170,7 @@ protected function grabLimit()
*/
protected function orderBy()
{
$orders = explode(',', Input::get('orderBy'));
$orders = explode(',', $this->request->input('orderBy'));

foreach ($orders as $order) {
if (!empty($order)) {
Expand Down Expand Up @@ -212,7 +216,7 @@ protected function selectFields()
*/
protected function includeRelations()
{
$includes = explode(',', Input::get('include', ''));
$includes = explode(',', $this->request->input('include', ''));

foreach ($includes as $relation) {
if (!empty($relation)) {
Expand All @@ -230,7 +234,7 @@ protected function includeRelations()
*/
protected function filter()
{
$filterList = Input::get('filter');
$filterList = $this->request->input('filter');

$FilterClass = $this->model->getFilterClass();

Expand Down Expand Up @@ -311,7 +315,7 @@ private function fieldsetBelongsToModel($fieldset)
*/
private function grabFields()
{
$fields = Input::get('fields', []);
$fields = $this->request->input('fields', []);
return (is_array($fields)) ? $fields : [$fields];
}
}

0 comments on commit c2643f0

Please sign in to comment.