@@ -71,7 +71,7 @@ |
||
71 | 71 | /** |
72 | 72 | * Get column value from instance. |
73 | 73 | * |
74 | - * @param Collection|Model $instance |
|
74 | + * @param Model $instance |
|
75 | 75 | * @param string $name |
76 | 76 | * |
77 | 77 | * @return mixed |
@@ -87,11 +87,11 @@ |
||
87 | 87 | |
88 | 88 | if ($instance instanceof Collection) { |
89 | 89 | $instance = $instance->pluck($part); |
90 | - } elseif (! is_null($instance)) { |
|
90 | + } elseif (!is_null($instance)) { |
|
91 | 91 | $instance = $instance->getAttribute($part); |
92 | 92 | } |
93 | 93 | |
94 | - if (! empty($parts) && ! is_null($instance)) { |
|
94 | + if (!empty($parts) && !is_null($instance)) { |
|
95 | 95 | return $this->getValueFromObject($instance, implode('.', $parts)); |
96 | 96 | } |
97 | 97 |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Get instance move up url. |
87 | - * @return Route |
|
87 | + * @return string |
|
88 | 88 | */ |
89 | 89 | protected function moveUpUrl() |
90 | 90 | { |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | /** |
107 | 107 | * Get instance move down url. |
108 | - * @return Route |
|
108 | + * @return string |
|
109 | 109 | */ |
110 | 110 | protected function moveDownUrl() |
111 | 111 | { |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | { |
18 | 18 | Route::post('{adminModel}/{adminModelId}/up', [ |
19 | 19 | 'as' => 'admin.model.move-up', |
20 | - function ($model, $id) { |
|
20 | + function($model, $id) { |
|
21 | 21 | $instance = $model->getRepository()->find($id); |
22 | 22 | $instance->moveUp(); |
23 | 23 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | Route::post('{adminModel}/{adminModelId}/down', [ |
29 | 29 | 'as' => 'admin.model.move-down', |
30 | - function ($model, $id) { |
|
30 | + function($model, $id) { |
|
31 | 31 | $instance = $model->getRepository()->find($id); |
32 | 32 | $instance->moveDown(); |
33 | 33 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function getModel() |
50 | 50 | { |
51 | - if (! in_array(OrderableModel::class, trait_uses_recursive($class = get_class($this->model)))) { |
|
51 | + if (!in_array(OrderableModel::class, trait_uses_recursive($class = get_class($this->model)))) { |
|
52 | 52 | throw new \Exception("Model [$class] should uses trait [SleepingOwl\\Admin\\Traits\\OrderableModel]"); |
53 | 53 | } |
54 | 54 |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
125 | - * @param mixed $distinct |
|
125 | + * @param string|null $distinct |
|
126 | 126 | * |
127 | 127 | * @return $this |
128 | 128 | */ |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | /** |
166 | 166 | * Apply offset and limit to the query. |
167 | 167 | * |
168 | - * @param $query |
|
168 | + * @param Builder $query |
|
169 | 169 | */ |
170 | 170 | protected function applyOffset($query) |
171 | 171 | { |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | /** |
183 | 183 | * Apply orders to the query. |
184 | 184 | * |
185 | - * @param $query |
|
185 | + * @param Builder $query |
|
186 | 186 | */ |
187 | 187 | protected function applyOrders($query) |
188 | 188 | { |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | /** |
248 | 248 | * Convert collection to the datatables structure. |
249 | 249 | * |
250 | - * @param array|Collection $collection |
|
250 | + * @param Collection $collection |
|
251 | 251 | * @param int $totalCount |
252 | 252 | * @param int $filteredCount |
253 | 253 | * |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public static function registerRoutes() |
20 | 20 | { |
21 | - Route::get('{adminModel}/async/{adminDisplayName?}', ['as' => 'admin.model.async', |
|
22 | - function (ModelConfigurationInterface $model, $name = null) { |
|
21 | + Route::get('{adminModel}/async/{adminDisplayName?}', [ 'as' => 'admin.model.async', |
|
22 | + function(ModelConfigurationInterface $model, $name = null) { |
|
23 | 23 | $display = $model->fireDisplay(); |
24 | 24 | if ($display instanceof DisplayTabbed) { |
25 | 25 | $display = static::findDatatablesAsyncByName($display, $name); |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $totalCount = $query->count(); |
144 | 144 | $filteredCount = 0; |
145 | 145 | |
146 | - if (! is_null($this->distinct)) { |
|
146 | + if (!is_null($this->distinct)) { |
|
147 | 147 | $filteredCount = $query->distinct()->count($this->getDistinct()); |
148 | 148 | } |
149 | 149 | |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | */ |
187 | 187 | protected function applyOrders($query) |
188 | 188 | { |
189 | - $orders = Request::input('order', []); |
|
189 | + $orders = Request::input('order', [ ]); |
|
190 | 190 | |
191 | 191 | foreach ($orders as $order) { |
192 | - $columnIndex = $order['column']; |
|
193 | - $orderDirection = $order['dir']; |
|
192 | + $columnIndex = $order[ 'column' ]; |
|
193 | + $orderDirection = $order[ 'dir' ]; |
|
194 | 194 | $column = $this->getColumns()->all()->get($columnIndex); |
195 | 195 | |
196 | 196 | if ($column instanceof NamedColumn && $column->isOrderable()) { |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | return; |
213 | 213 | } |
214 | 214 | |
215 | - $query->where(function ($query) use ($search) { |
|
215 | + $query->where(function($query) use ($search) { |
|
216 | 216 | $columns = $this->getColumns()->all(); |
217 | 217 | foreach ($columns as $column) { |
218 | 218 | if ($column instanceof Text) { |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | */ |
231 | 231 | protected function applyColumnSearch(Builder $query) |
232 | 232 | { |
233 | - $queryColumns = Request::input('columns', []); |
|
233 | + $queryColumns = Request::input('columns', [ ]); |
|
234 | 234 | |
235 | 235 | foreach ($queryColumns as $index => $queryColumn) { |
236 | 236 | $search = array_get($queryColumn, 'search.value'); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $column = $this->getColumns()->all()->get($index); |
239 | 239 | $columnFilter = array_get($this->getColumnFilters()->all(), $index); |
240 | 240 | |
241 | - if (! is_null($columnFilter) && ! is_null($column)) { |
|
241 | + if (!is_null($columnFilter) && !is_null($column)) { |
|
242 | 242 | $columnFilter->apply($this->repository, $column, $query, $search, $fullSearch); |
243 | 243 | } |
244 | 244 | } |
@@ -257,21 +257,21 @@ discard block |
||
257 | 257 | { |
258 | 258 | $columns = $this->getColumns(); |
259 | 259 | |
260 | - $result = []; |
|
261 | - $result['draw'] = Request::input('draw', 0); |
|
262 | - $result['recordsTotal'] = $totalCount; |
|
263 | - $result['recordsFiltered'] = $filteredCount; |
|
264 | - $result['data'] = []; |
|
260 | + $result = [ ]; |
|
261 | + $result[ 'draw' ] = Request::input('draw', 0); |
|
262 | + $result[ 'recordsTotal' ] = $totalCount; |
|
263 | + $result[ 'recordsFiltered' ] = $filteredCount; |
|
264 | + $result[ 'data' ] = [ ]; |
|
265 | 265 | |
266 | 266 | foreach ($collection as $instance) { |
267 | - $_row = []; |
|
267 | + $_row = [ ]; |
|
268 | 268 | |
269 | 269 | foreach ($columns->all() as $column) { |
270 | 270 | $column->setModel($instance); |
271 | - $_row[] = (string) $column; |
|
271 | + $_row[ ] = (string) $column; |
|
272 | 272 | } |
273 | 273 | |
274 | - $result['data'][] = $_row; |
|
274 | + $result[ 'data' ][ ] = $_row; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | return $result; |
@@ -197,7 +197,7 @@ |
||
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
200 | - * @param \Illuminate\Database\Eloquent\Builder|Builder $query |
|
200 | + * @param \Illuminate\Database\Eloquent\Builder $query |
|
201 | 201 | */ |
202 | 202 | protected function modifyQuery(\Illuminate\Database\Eloquent\Builder $query) |
203 | 203 | { |
@@ -13,7 +13,6 @@ |
||
13 | 13 | |
14 | 14 | /** |
15 | 15 | * Class DisplayTable. |
16 | - |
|
17 | 16 | * @method Columns getColumns() |
18 | 17 | * @method $this setColumns(ColumnInterface $column, ... $columns) |
19 | 18 | * |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @var array |
32 | 32 | */ |
33 | - protected $parameters = []; |
|
33 | + protected $parameters = [ ]; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * @var int|null |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | parent::initialize(); |
67 | 67 | |
68 | 68 | if ($this->getModelConfiguration()->isRestorableModel()) { |
69 | - $this->setApply(function ($q) { |
|
69 | + $this->setApply(function($q) { |
|
70 | 70 | return $q->withTrashed(); |
71 | 71 | }); |
72 | 72 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function setParameter($key, $value) |
104 | 104 | { |
105 | - $this->parameters[$key] = $value; |
|
105 | + $this->parameters[ $key ] = $value; |
|
106 | 106 | |
107 | 107 | return $this; |
108 | 108 | } |
@@ -148,15 +148,15 @@ discard block |
||
148 | 148 | |
149 | 149 | $params = parent::toArray(); |
150 | 150 | |
151 | - $params['creatable'] = $model->isCreatable(); |
|
152 | - $params['createUrl'] = $model->getCreateUrl($this->getParameters() + Request::all()); |
|
153 | - $params['collection'] = $this->getCollection(); |
|
151 | + $params[ 'creatable' ] = $model->isCreatable(); |
|
152 | + $params[ 'createUrl' ] = $model->getCreateUrl($this->getParameters() + Request::all()); |
|
153 | + $params[ 'collection' ] = $this->getCollection(); |
|
154 | 154 | |
155 | - $params['extensions'] = $this->getExtensions() |
|
156 | - ->filter(function (DisplayExtensionInterface $ext) { |
|
155 | + $params[ 'extensions' ] = $this->getExtensions() |
|
156 | + ->filter(function(DisplayExtensionInterface $ext) { |
|
157 | 157 | return $ext instanceof Renderable; |
158 | 158 | }) |
159 | - ->sortBy(function (DisplayExtensionInterface $extension) { |
|
159 | + ->sortBy(function(DisplayExtensionInterface $extension) { |
|
160 | 160 | return $extension->getOrder(); |
161 | 161 | }); |
162 | 162 | |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function getCollection() |
181 | 181 | { |
182 | - if (! $this->isInitialized()) { |
|
182 | + if (!$this->isInitialized()) { |
|
183 | 183 | throw new \Exception('Display is not initialized'); |
184 | 184 | } |
185 | 185 | |
186 | - if (! is_null($this->collection)) { |
|
186 | + if (!is_null($this->collection)) { |
|
187 | 187 | return $this->collection; |
188 | 188 | } |
189 | 189 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $this->modifyQuery($query); |
193 | 193 | |
194 | 194 | return $this->collection = $this->usePagination() |
195 | - ? $query->paginate($this->paginate, ['*'], $this->pageName) |
|
195 | + ? $query->paginate($this->paginate, [ '*' ], $this->pageName) |
|
196 | 196 | : $query->get(); |
197 | 197 | } |
198 | 198 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | protected function modifyQuery(\Illuminate\Database\Eloquent\Builder $query) |
203 | 203 | { |
204 | - $this->extensions->each(function (DisplayExtensionInterface $extension) use ($query) { |
|
204 | + $this->extensions->each(function(DisplayExtensionInterface $extension) use ($query) { |
|
205 | 205 | $extension->modifyQuery($query); |
206 | 206 | }); |
207 | 207 | } |
@@ -283,7 +283,7 @@ |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
286 | - * @param \Illuminate\Database\Eloquent\Builder|Builder $query |
|
286 | + * @param \Illuminate\Database\Eloquent\Builder $query |
|
287 | 287 | */ |
288 | 288 | protected function modifyQuery(\Illuminate\Database\Eloquent\Builder $query) |
289 | 289 | { |
@@ -89,9 +89,9 @@ |
||
89 | 89 | parent::initialize(); |
90 | 90 | |
91 | 91 | $this->getRepository() |
92 | - ->setParentField($this->getParentField()) |
|
93 | - ->setOrderField($this->getOrderField()) |
|
94 | - ->setRootParentId($this->getRootParentId()); |
|
92 | + ->setParentField($this->getParentField()) |
|
93 | + ->setOrderField($this->getOrderField()) |
|
94 | + ->setRootParentId($this->getRootParentId()); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | public static function registerRoutes() |
22 | 22 | { |
23 | - Route::post('{adminModel}/reorder', function (ModelConfigurationInterface $model) { |
|
23 | + Route::post('{adminModel}/reorder', function(ModelConfigurationInterface $model) { |
|
24 | 24 | $model->fireDisplay()->getRepository()->reorder( |
25 | 25 | Request::input('data') |
26 | 26 | ); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @var array |
37 | 37 | */ |
38 | - protected $parameters = []; |
|
38 | + protected $parameters = [ ]; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @var bool |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function setParameter($key, $value) |
204 | 204 | { |
205 | - $this->parameters[$key] = $value; |
|
205 | + $this->parameters[ $key ] = $value; |
|
206 | 206 | |
207 | 207 | return $this; |
208 | 208 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | 'value' => $this->getValue(), |
250 | 250 | 'creatable' => $model->isCreatable(), |
251 | 251 | 'createUrl' => $model->getCreateUrl($this->getParameters() + Request::all()), |
252 | - 'controls' => [app('sleeping_owl.table.column')->treeControl()], |
|
252 | + 'controls' => [ app('sleeping_owl.table.column')->treeControl() ], |
|
253 | 253 | ]; |
254 | 254 | } |
255 | 255 | |
@@ -267,11 +267,11 @@ discard block |
||
267 | 267 | */ |
268 | 268 | public function getCollection() |
269 | 269 | { |
270 | - if (! $this->isInitialized()) { |
|
270 | + if (!$this->isInitialized()) { |
|
271 | 271 | throw new \Exception('Display is not initialized'); |
272 | 272 | } |
273 | 273 | |
274 | - if (! is_null($this->collection)) { |
|
274 | + if (!is_null($this->collection)) { |
|
275 | 275 | return $this->collection; |
276 | 276 | } |
277 | 277 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | */ |
288 | 288 | protected function modifyQuery(\Illuminate\Database\Eloquent\Builder $query) |
289 | 289 | { |
290 | - $this->extensions->each(function (DisplayExtensionInterface $extension) use ($query) { |
|
290 | + $this->extensions->each(function(DisplayExtensionInterface $extension) use ($query) { |
|
291 | 291 | $extension->modifyQuery($query); |
292 | 292 | }); |
293 | 293 | } |
@@ -45,7 +45,7 @@ |
||
45 | 45 | /** |
46 | 46 | * @param ActionInterface $actions |
47 | 47 | * |
48 | - * @return $this |
|
48 | + * @return \SleepingOwl\Admin\Contracts\DisplayInterface |
|
49 | 49 | */ |
50 | 50 | public function set($actions) |
51 | 51 | { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function set($actions) |
51 | 51 | { |
52 | - if (! is_array($actions)) { |
|
52 | + if (!is_array($actions)) { |
|
53 | 53 | $actions = func_get_args(); |
54 | 54 | } |
55 | 55 | |
@@ -145,13 +145,13 @@ discard block |
||
145 | 145 | return; |
146 | 146 | } |
147 | 147 | |
148 | - $this->all()->each(function (ActionInterface $action) { |
|
148 | + $this->all()->each(function(ActionInterface $action) { |
|
149 | 149 | $action->initialize(); |
150 | 150 | }); |
151 | 151 | |
152 | 152 | $this->setHtmlAttribute('data-type', 'display-actions'); |
153 | 153 | |
154 | - if (! $this->hasHtmlAttribute('class')) { |
|
154 | + if (!$this->hasHtmlAttribute('class')) { |
|
155 | 155 | $this->setHtmlAttribute('class', 'panel-footer'); |
156 | 156 | } |
157 | 157 | } |
@@ -48,7 +48,7 @@ |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | - * @return Collection|\SleepingOwl\Admin\Contracts\ActionInterface[] |
|
51 | + * @return ColumnFilterInterface[] |
|
52 | 52 | */ |
53 | 53 | public function all() |
54 | 54 | { |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * @var ColumnFilterInterface[] |
17 | 17 | */ |
18 | - protected $columnFilters = []; |
|
18 | + protected $columnFilters = [ ]; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @var string|\Illuminate\View\View |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function set($columnFilters) |
36 | 36 | { |
37 | - if (! is_array($columnFilters)) { |
|
37 | + if (!is_array($columnFilters)) { |
|
38 | 38 | $columnFilters = func_get_args(); |
39 | 39 | } |
40 | 40 | |
41 | - $this->columnFilters = []; |
|
41 | + $this->columnFilters = [ ]; |
|
42 | 42 | |
43 | 43 | foreach ($columnFilters as $filter) { |
44 | 44 | $this->push($filter); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function push(ColumnFilterInterface $filter = null) |
64 | 64 | { |
65 | - $this->columnFilters[] = $filter; |
|
65 | + $this->columnFilters[ ] = $filter; |
|
66 | 66 | |
67 | 67 | return $this; |
68 | 68 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | - if (! $this->hasHtmlAttribute('class')) { |
|
158 | + if (!$this->hasHtmlAttribute('class')) { |
|
159 | 159 | $this->setHtmlAttribute('class', 'panel-footer'); |
160 | 160 | } |
161 | 161 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | - * @return string|\Illuminate\View\View |
|
127 | + * @return string |
|
128 | 128 | */ |
129 | 129 | public function getView() |
130 | 130 | { |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * @param string|\Illuminate\View\View $view |
|
135 | + * @param string $view |
|
136 | 136 | * |
137 | 137 | * @return $this |
138 | 138 | */ |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function set($columns) |
102 | 102 | { |
103 | - if (! is_array($columns)) { |
|
103 | + if (!is_array($columns)) { |
|
104 | 104 | $columns = func_get_args(); |
105 | 105 | } |
106 | 106 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $this->push($this->getControlColumn()); |
163 | 163 | } |
164 | 164 | |
165 | - $this->all()->each(function (ColumnInterface $column) { |
|
165 | + $this->all()->each(function(ColumnInterface $column) { |
|
166 | 166 | $column->initialize(); |
167 | 167 | }); |
168 | 168 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | public function render() |
176 | 176 | { |
177 | 177 | $params = $this->toArray(); |
178 | - $params['collection'] = $this->getDisplay()->getCollection(); |
|
178 | + $params[ 'collection' ] = $this->getDisplay()->getCollection(); |
|
179 | 179 | |
180 | 180 | return app('sleeping_owl.template')->view($this->getView(), $params)->render(); |
181 | 181 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | /** |
23 | 23 | * @param array|string $scopes |
24 | 24 | * |
25 | - * @return $this |
|
25 | + * @return \SleepingOwl\Admin\Contracts\DisplayInterface |
|
26 | 26 | */ |
27 | 27 | public function set($scopes) |
28 | 28 | { |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | /** |
10 | 10 | * @var string[] |
11 | 11 | */ |
12 | - protected $scopes = []; |
|
12 | + protected $scopes = [ ]; |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * @return string[] |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function push($scope) |
40 | 40 | { |
41 | - if (! is_array($scope)) { |
|
41 | + if (!is_array($scope)) { |
|
42 | 42 | $scope = func_get_args(); |
43 | 43 | } |
44 | 44 | |
45 | - $this->scopes[] = $scope; |
|
45 | + $this->scopes[ ] = $scope; |
|
46 | 46 | |
47 | 47 | return $this; |
48 | 48 | } |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | public function modifyQuery(Builder $query) |
66 | 66 | { |
67 | 67 | foreach ($this->scopes as $scope) { |
68 | - if (! is_null($scope)) { |
|
68 | + if (!is_null($scope)) { |
|
69 | 69 | if (is_array($scope)) { |
70 | 70 | $method = array_shift($scope); |
71 | 71 | $params = $scope; |
72 | 72 | } else { |
73 | 73 | $method = $scope; |
74 | - $params = []; |
|
74 | + $params = [ ]; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | call_user_func_array([ |