@@ -36,8 +36,9 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function builder(Builder $query) |
| 38 | 38 | { |
| 39 | - if (is_null($this->filters)) |
|
| 40 | - return $query; |
|
| 39 | + if (is_null($this->filters)) { |
|
| 40 | + return $query; |
|
| 41 | + } |
|
| 41 | 42 | foreach ($this->filters as $filter) { |
| 42 | 43 | if (is_array($filter[1])) { |
| 43 | 44 | $query = $query->whereBetween($filter[0], $filter[1]); |
@@ -69,8 +70,9 @@ discard block |
||
| 69 | 70 | */ |
| 70 | 71 | private function requestParser($request) |
| 71 | 72 | { |
| 72 | - if (empty($request)) |
|
| 73 | - return; |
|
| 73 | + if (empty($request)) { |
|
| 74 | + return; |
|
| 75 | + } |
|
| 74 | 76 | |
| 75 | 77 | $this->chackSortFilter($request); |
| 76 | 78 | |
@@ -88,16 +90,15 @@ discard block |
||
| 88 | 90 | { |
| 89 | 91 | if (strpos(array_keys($request)[0], 'asc') || strpos(array_keys($request)[0], 'desc')) { |
| 90 | 92 | list($this->filterString, $this->sort) = explode(',', array_keys($request)[0]); |
| 91 | - if (strpos($this->sort, 'By')) |
|
| 92 | - $this->sort = explode('By', $this->sort); |
|
| 93 | - else { |
|
| 93 | + if (strpos($this->sort, 'By')) { |
|
| 94 | + $this->sort = explode('By', $this->sort); |
|
| 95 | + } else { |
|
| 94 | 96 | $this->sort = str_split($this->sort, 4); |
| 95 | 97 | $this->sort[] = $this->getStringFilters(); |
| 96 | 98 | } |
| 99 | + } else { |
|
| 100 | + $this->filterString = array_keys($request)[0]; |
|
| 97 | 101 | } |
| 98 | - |
|
| 99 | - else |
|
| 100 | - $this->filterString = array_keys($request)[0]; |
|
| 101 | 102 | } |
| 102 | 103 | |
| 103 | 104 | /** |
@@ -108,10 +109,11 @@ discard block |
||
| 108 | 109 | */ |
| 109 | 110 | private function setSortFilter($query) |
| 110 | 111 | { |
| 111 | - if (is_null($this->sort)) |
|
| 112 | - return $query; |
|
| 113 | - else |
|
| 114 | - return $query->orderBy($this->sort[1], $this->sort[0]); |
|
| 112 | + if (is_null($this->sort)) { |
|
| 113 | + return $query; |
|
| 114 | + } else { |
|
| 115 | + return $query->orderBy($this->sort[1], $this->sort[0]); |
|
| 116 | + } |
|
| 115 | 117 | } |
| 116 | 118 | |
| 117 | 119 | /** |
@@ -156,8 +158,7 @@ discard block |
||
| 156 | 158 | $filters[$current][1] = explode('-', $filter[1]); |
| 157 | 159 | } |
| 158 | 160 | $current++; |
| 159 | - } |
|
| 160 | - else { |
|
| 161 | + } else { |
|
| 161 | 162 | unset($filters[$current]); |
| 162 | 163 | $current++; |
| 163 | 164 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (! function_exists('getInstanceFilter')) { |
|
| 3 | +if (!function_exists('getInstanceFilter')) { |
|
| 4 | 4 | /** |
| 5 | 5 | * Get the available filter instance. |
| 6 | 6 | * |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | } |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | -if (! function_exists('filter')) { |
|
| 20 | +if (!function_exists('filter')) { |
|
| 21 | 21 | /** |
| 22 | 22 | * Make the filter querty string. |
| 23 | 23 | * |