@@ -14,5 +14,5 @@ |
||
| 14 | 14 | * @param mixed $queryBuilder Current query builder. |
| 15 | 15 | * @return mixed $queryBuilder Current instance of the query builder with the criteria appplied. |
| 16 | 16 | */ |
| 17 | - public function apply( $queryBuilder ); |
|
| 17 | + public function apply($queryBuilder); |
|
| 18 | 18 | } |
| 19 | 19 | \ No newline at end of file |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | /** |
| 17 | 17 | * @param array $filter |
| 18 | 18 | */ |
| 19 | - public function __construct( array $filter ) |
|
| 19 | + public function __construct(array $filter) |
|
| 20 | 20 | { |
| 21 | 21 | $this->filter = $filter; |
| 22 | 22 | } |
@@ -26,26 +26,26 @@ discard block |
||
| 26 | 26 | * @param $modelOrBuilder |
| 27 | 27 | * @return mixed |
| 28 | 28 | */ |
| 29 | - public function apply( $modelOrBuilder ) |
|
| 29 | + public function apply($modelOrBuilder) |
|
| 30 | 30 | { |
| 31 | - foreach( $this->filter as $filter ) |
|
| 31 | + foreach ($this->filter as $filter) |
|
| 32 | 32 | { |
| 33 | - $nElements = count( $filter ); |
|
| 33 | + $nElements = count($filter); |
|
| 34 | 34 | |
| 35 | 35 | // Apply filter based on then number of items in the array. |
| 36 | - if ( $nElements === 2 ) |
|
| 36 | + if ($nElements === 2) |
|
| 37 | 37 | { |
| 38 | 38 | $column = $filter[0]; |
| 39 | 39 | $operation = NULL; |
| 40 | 40 | $value = $filter[1]; |
| 41 | - } else if ( $nElements === 3 ) |
|
| 41 | + } else if ($nElements === 3) |
|
| 42 | 42 | { |
| 43 | 43 | $column = $filter[0]; |
| 44 | 44 | $operation = $filter[1]; |
| 45 | 45 | $value = $filter[2]; |
| 46 | 46 | } else continue; |
| 47 | 47 | |
| 48 | - $modelOrBuilder = $this->applyFilter( $modelOrBuilder, $column, $value, $operation ); |
|
| 48 | + $modelOrBuilder = $this->applyFilter($modelOrBuilder, $column, $value, $operation); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | return $modelOrBuilder; |
@@ -58,10 +58,10 @@ discard block |
||
| 58 | 58 | * @param $value |
| 59 | 59 | * @param null $operation |
| 60 | 60 | */ |
| 61 | - private function applyFilter( $modelOrBuilder, $column, $value, $operation = NULL ) |
|
| 61 | + private function applyFilter($modelOrBuilder, $column, $value, $operation = NULL) |
|
| 62 | 62 | { |
| 63 | - if ( is_null( $operation ) ) $modelOrBuilder = $modelOrBuilder->where( $column, $value ); |
|
| 64 | - else $modelOrBuilder = $modelOrBuilder->where( $column, $operation, $value ); |
|
| 63 | + if (is_null($operation)) $modelOrBuilder = $modelOrBuilder->where($column, $value); |
|
| 64 | + else $modelOrBuilder = $modelOrBuilder->where($column, $operation, $value); |
|
| 65 | 65 | |
| 66 | 66 | return $modelOrBuilder; |
| 67 | 67 | } |
@@ -43,7 +43,9 @@ discard block |
||
| 43 | 43 | $column = $filter[0]; |
| 44 | 44 | $operation = $filter[1]; |
| 45 | 45 | $value = $filter[2]; |
| 46 | - } else continue; |
|
| 46 | + } else { |
|
| 47 | + continue; |
|
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | $modelOrBuilder = $this->applyFilter( $modelOrBuilder, $column, $value, $operation ); |
| 49 | 51 | } |
@@ -60,8 +62,11 @@ discard block |
||
| 60 | 62 | */ |
| 61 | 63 | private function applyFilter( $modelOrBuilder, $column, $value, $operation = NULL ) |
| 62 | 64 | { |
| 63 | - if ( is_null( $operation ) ) $modelOrBuilder = $modelOrBuilder->where( $column, $value ); |
|
| 64 | - else $modelOrBuilder = $modelOrBuilder->where( $column, $operation, $value ); |
|
| 65 | + if ( is_null( $operation ) ) { |
|
| 66 | + $modelOrBuilder = $modelOrBuilder->where( $column, $value ); |
|
| 67 | + } else { |
|
| 68 | + $modelOrBuilder = $modelOrBuilder->where( $column, $operation, $value ); |
|
| 69 | + } |
|
| 65 | 70 | |
| 66 | 71 | return $modelOrBuilder; |
| 67 | 72 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @param $orderBy |
| 19 | 19 | * @param string $direction |
| 20 | 20 | */ |
| 21 | - public function __construct( $orderBy, $direction = 'ASC' ) |
|
| 21 | + public function __construct($orderBy, $direction = 'ASC') |
|
| 22 | 22 | { |
| 23 | 23 | $this->orderBy = $orderBy; |
| 24 | 24 | $this->direction = $direction; |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | * @param mixed $queryBuilder |
| 30 | 30 | * @return mixed |
| 31 | 31 | */ |
| 32 | - public function apply( $queryBuilder ) |
|
| 32 | + public function apply($queryBuilder) |
|
| 33 | 33 | { |
| 34 | - return $queryBuilder->orderBy( $this->orderBy, $this->direction ); |
|
| 34 | + return $queryBuilder->orderBy($this->orderBy, $this->direction); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | |