@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * Filter constructor. |
44 | 44 | * @param Model $model |
45 | 45 | */ |
46 | - public function __construct( Model $model ) |
|
46 | + public function __construct(Model $model) |
|
47 | 47 | { |
48 | 48 | $this->model = $model; |
49 | 49 | $this->query = $model->newQuery(); |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | return; |
64 | 64 | } |
65 | 65 | |
66 | - $column = $columns->filter(function (Column $column) { |
|
66 | + $column = $columns->filter(function(Column $column) { |
|
67 | 67 | return $column->isSortable(); |
68 | - })->filter(function (Column $column) use ($orderBy) { |
|
68 | + })->filter(function(Column $column) use ($orderBy) { |
|
69 | 69 | return $column->getName() === $orderBy; |
70 | 70 | })->first(); |
71 | 71 | |
@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | * @param $phrase |
81 | 81 | * @param Collection|Column[] $columns |
82 | 82 | */ |
83 | - protected function search( $phrase, $columns ) |
|
83 | + protected function search($phrase, $columns) |
|
84 | 84 | { |
85 | - $keywords = explode( ' ', $phrase ); |
|
85 | + $keywords = explode(' ', $phrase); |
|
86 | 86 | |
87 | - foreach( $keywords as $string ) |
|
87 | + foreach ($keywords as $string) |
|
88 | 88 | { |
89 | - $this->query->where( function ( QueryBuilder $query ) use ( $string, $columns ) |
|
89 | + $this->query->where(function(QueryBuilder $query) use ($string, $columns) |
|
90 | 90 | { |
91 | - foreach( $columns as $column ) |
|
91 | + foreach ($columns as $column) |
|
92 | 92 | { |
93 | - if( !$column->isSearchable() ) |
|
93 | + if (!$column->isSearchable()) |
|
94 | 94 | { |
95 | 95 | continue; |
96 | 96 | } |
97 | 97 | |
98 | - $column->searchConditions( $query, $string ); |
|
98 | + $column->searchConditions($query, $string); |
|
99 | 99 | } |
100 | 100 | } ); |
101 | 101 | } |
@@ -108,25 +108,25 @@ discard block |
||
108 | 108 | { |
109 | 109 | $result = $this->query; |
110 | 110 | |
111 | - if (! $this->isPaginated()) { |
|
111 | + if (!$this->isPaginated()) { |
|
112 | 112 | return $result->get(); |
113 | 113 | } |
114 | 114 | |
115 | 115 | /** @var LengthAwarePaginator $result */ |
116 | - $result = $this->query->paginate( $this->getPerPage() ); |
|
116 | + $result = $this->query->paginate($this->getPerPage()); |
|
117 | 117 | |
118 | - if( $this->request->has( 'search' ) ) |
|
118 | + if ($this->request->has('search')) |
|
119 | 119 | { |
120 | 120 | $result->appends([ |
121 | - 'search' => $this->request->get( 'search' ), |
|
121 | + 'search' => $this->request->get('search'), |
|
122 | 122 | ]); |
123 | 123 | } |
124 | 124 | |
125 | - if( $this->request->has( '_order_by' ) && $this->request->has( '_order' ) ) |
|
125 | + if ($this->request->has('_order_by') && $this->request->has('_order')) |
|
126 | 126 | { |
127 | 127 | $result->appends([ |
128 | - '_order_by' => $this->request->get( '_order_by' ), |
|
129 | - '_order' => $this->request->get( '_order' ), |
|
128 | + '_order_by' => $this->request->get('_order_by'), |
|
129 | + '_order' => $this->request->get('_order'), |
|
130 | 130 | ]); |
131 | 131 | } |
132 | 132 | |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | * @param Collection|Column[] $columns |
138 | 138 | * @return Collection|LengthAwarePaginator |
139 | 139 | */ |
140 | - public function execute( Collection $columns ) |
|
140 | + public function execute(Collection $columns) |
|
141 | 141 | { |
142 | - if( $this->request->has( 'search' ) ) |
|
142 | + if ($this->request->has('search')) |
|
143 | 143 | { |
144 | - $this->search( $this->request->get( 'search' ), $columns ); |
|
144 | + $this->search($this->request->get('search'), $columns); |
|
145 | 145 | } |
146 | 146 | |
147 | - $this->order( $columns ); |
|
147 | + $this->order($columns); |
|
148 | 148 | |
149 | 149 | return $this->loadItems(); |
150 | 150 | } |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | /** |
153 | 153 | * @param $relationName |
154 | 154 | */ |
155 | - public function withRelation( $relationName ) |
|
155 | + public function withRelation($relationName) |
|
156 | 156 | { |
157 | - $this->query->with( $relationName ); |
|
157 | + $this->query->with($relationName); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | /** |
177 | 177 | * @param bool $paginated |
178 | 178 | */ |
179 | - public function setPaginated( bool $paginated ) |
|
179 | + public function setPaginated(bool $paginated) |
|
180 | 180 | { |
181 | 181 | $this->paginated = $paginated; |
182 | 182 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | /** |
193 | 193 | * @param int $perPage |
194 | 194 | */ |
195 | - public function setPerPage( int $perPage ) |
|
195 | + public function setPerPage(int $perPage) |
|
196 | 196 | { |
197 | 197 | $this->perPage = $perPage; |
198 | 198 | } |