@@ -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 | { |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | { |
16 | 16 | Route::post('{adminModel}/{adminModelId}/up', [ |
17 | 17 | 'as' => 'admin.model.move-up', |
18 | - function ($model, $id) { |
|
18 | + function($model, $id) { |
|
19 | 19 | $instance = $model->getRepository()->find($id); |
20 | 20 | $instance->moveUp(); |
21 | 21 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | Route::post('{adminModel}/{adminModelId}/down', [ |
27 | 27 | 'as' => 'admin.model.move-down', |
28 | - function ($model, $id) { |
|
28 | + function($model, $id) { |
|
29 | 29 | $instance = $model->getRepository()->find($id); |
30 | 30 | $instance->moveDown(); |
31 | 31 |
@@ -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 (ModelConfiguration $model, $name = null) { |
|
21 | + Route::get('{adminModel}/async/{adminDisplayName?}', [ 'as' => 'admin.model.async', |
|
22 | + function(ModelConfiguration $model, $name = null) { |
|
23 | 23 | $display = $model->fireDisplay(); |
24 | 24 | if ($display instanceof DisplayTabbed) { |
25 | 25 | $display = static::findDatatablesAsyncByName($display, $name); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $totalCount = $query->count(); |
136 | 136 | $filteredCount = 0; |
137 | 137 | |
138 | - if (! is_null($this->distinct)) { |
|
138 | + if (!is_null($this->distinct)) { |
|
139 | 139 | $filteredCount = $query->distinct()->count($this->getDistinct()); |
140 | 140 | } |
141 | 141 | |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | */ |
179 | 179 | protected function applyOrders($query) |
180 | 180 | { |
181 | - $orders = Request::input('order', []); |
|
181 | + $orders = Request::input('order', [ ]); |
|
182 | 182 | |
183 | 183 | foreach ($orders as $order) { |
184 | - $columnIndex = $order['column']; |
|
185 | - $orderDirection = $order['dir']; |
|
184 | + $columnIndex = $order[ 'column' ]; |
|
185 | + $orderDirection = $order[ 'dir' ]; |
|
186 | 186 | $column = $this->getColumns()->all()->get($columnIndex); |
187 | 187 | |
188 | 188 | if ($column instanceof NamedColumn && $column->isOrderable()) { |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | return; |
205 | 205 | } |
206 | 206 | |
207 | - $query->where(function ($query) use ($search) { |
|
207 | + $query->where(function($query) use ($search) { |
|
208 | 208 | $columns = $this->getColumns()->all(); |
209 | 209 | foreach ($columns as $column) { |
210 | 210 | if ($column instanceof Text) { |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | protected function applyColumnSearch(Builder $query) |
224 | 224 | { |
225 | - $queryColumns = Request::input('columns', []); |
|
225 | + $queryColumns = Request::input('columns', [ ]); |
|
226 | 226 | |
227 | 227 | foreach ($queryColumns as $index => $queryColumn) { |
228 | 228 | $search = array_get($queryColumn, 'search.value'); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $column = $this->getColumns()->all()->get($index); |
231 | 231 | $columnFilter = array_get($this->getColumnFilters()->all(), $index); |
232 | 232 | |
233 | - if (! is_null($columnFilter) && ! is_null($column)) { |
|
233 | + if (!is_null($columnFilter) && !is_null($column)) { |
|
234 | 234 | $columnFilter->apply($this->repository, $column, $query, $search, $fullSearch); |
235 | 235 | } |
236 | 236 | } |
@@ -249,21 +249,21 @@ discard block |
||
249 | 249 | { |
250 | 250 | $columns = $this->getColumns(); |
251 | 251 | |
252 | - $result = []; |
|
253 | - $result['draw'] = Request::input('draw', 0); |
|
254 | - $result['recordsTotal'] = $totalCount; |
|
255 | - $result['recordsFiltered'] = $filteredCount; |
|
256 | - $result['data'] = []; |
|
252 | + $result = [ ]; |
|
253 | + $result[ 'draw' ] = Request::input('draw', 0); |
|
254 | + $result[ 'recordsTotal' ] = $totalCount; |
|
255 | + $result[ 'recordsFiltered' ] = $filteredCount; |
|
256 | + $result[ 'data' ] = [ ]; |
|
257 | 257 | |
258 | 258 | foreach ($collection as $instance) { |
259 | - $_row = []; |
|
259 | + $_row = [ ]; |
|
260 | 260 | |
261 | 261 | foreach ($columns->all() as $column) { |
262 | 262 | $column->setModel($instance); |
263 | - $_row[] = (string) $column; |
|
263 | + $_row[ ] = (string) $column; |
|
264 | 264 | } |
265 | 265 | |
266 | - $result['data'][] = $_row; |
|
266 | + $result[ 'data' ][ ] = $_row; |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | return $result; |
@@ -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 | { |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @var ColumnFilterInterface[] |
16 | 16 | */ |
17 | - protected $columnFilters = []; |
|
17 | + protected $columnFilters = [ ]; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @var string |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function set($columnFilters) |
35 | 35 | { |
36 | - if (! is_array($columnFilters)) { |
|
36 | + if (!is_array($columnFilters)) { |
|
37 | 37 | $columnFilters = func_get_args(); |
38 | 38 | } |
39 | 39 | |
40 | - $this->columnFilters = []; |
|
40 | + $this->columnFilters = [ ]; |
|
41 | 41 | |
42 | 42 | foreach ($columnFilters as $filter) { |
43 | 43 | $this->push($filter); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function push(ColumnFilterInterface $filter = null) |
63 | 63 | { |
64 | - $this->columnFilters[] = $filter; |
|
64 | + $this->columnFilters[ ] = $filter; |
|
65 | 65 | |
66 | 66 | return $this; |
67 | 67 | } |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | - if (! $this->hasHtmlAttribute('class')) { |
|
137 | + if (!$this->hasHtmlAttribute('class')) { |
|
138 | 138 | $this->setHtmlAttribute('class', 'panel-footer'); |
139 | 139 | } |
140 | 140 | |
141 | 141 | $template = app('sleeping_owl.template')->getViewPath($this->getDisplay()->getView()); |
142 | 142 | |
143 | - view()->composer($template, function (\Illuminate\View\View $view) { |
|
143 | + view()->composer($template, function(\Illuminate\View\View $view) { |
|
144 | 144 | $view->getFactory()->inject( |
145 | 145 | $this->getPosition(), |
146 | 146 | app('sleeping_owl.template')->view($this->getView(), $this->toArray()) |
@@ -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([ |
@@ -35,7 +35,7 @@ |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | - * @return array |
|
38 | + * @return Collection |
|
39 | 39 | */ |
40 | 40 | public function getColumns() |
41 | 41 | { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | parent::initialize(); |
29 | 29 | |
30 | - $this->applyCallbackToItems(function ($item) { |
|
30 | + $this->applyCallbackToItems(function($item) { |
|
31 | 31 | if ($item instanceof Initializable) { |
32 | 32 | $item->initialize(); |
33 | 33 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | parent::setModel($model); |
67 | 67 | |
68 | - $this->applyCallbackToItems(function ($item) use ($model) { |
|
68 | + $this->applyCallbackToItems(function($item) use ($model) { |
|
69 | 69 | if ($item instanceof FormElementInterface) { |
70 | 70 | $item->setModel($model); |
71 | 71 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function getValidationMessages() |
113 | 113 | { |
114 | - $messages = []; |
|
114 | + $messages = [ ]; |
|
115 | 115 | |
116 | 116 | foreach ($this->getColumns() as $columnItems) { |
117 | 117 | foreach ($columnItems as $item) { |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function getValidationLabels() |
131 | 131 | { |
132 | - $labels = []; |
|
132 | + $labels = [ ]; |
|
133 | 133 | |
134 | 134 | foreach ($this->getColumns() as $columnItems) { |
135 | 135 | foreach ($columnItems as $item) { |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | { |
147 | 147 | parent::save(); |
148 | 148 | |
149 | - $this->applyCallbackToItems(function ($item) { |
|
149 | + $this->applyCallbackToItems(function($item) { |
|
150 | 150 | if ($item instanceof FormElementInterface) { |
151 | 151 | $item->save(); |
152 | 152 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | { |
158 | 158 | parent::afterSave(); |
159 | 159 | |
160 | - $this->applyCallbackToItems(function ($item) { |
|
160 | + $this->applyCallbackToItems(function($item) { |
|
161 | 161 | if ($item instanceof FormElementInterface) { |
162 | 162 | $item->afterSave(); |
163 | 163 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | - * @return \string[] |
|
63 | + * @return string[] |
|
64 | 64 | */ |
65 | 65 | public function getWith() |
66 | 66 | { |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Get base query. |
84 | - * @return mixed |
|
84 | + * @return \Illuminate\Database\Eloquent\Builder |
|
85 | 85 | */ |
86 | 86 | public function getQuery() |
87 | 87 | { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * Eager loading relations. |
26 | 26 | * @var string[] |
27 | 27 | */ |
28 | - protected $with = []; |
|
28 | + protected $with = [ ]; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @param string $class |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function with($with) |
74 | 74 | { |
75 | - if (! is_array($with)) { |
|
75 | + if (!is_array($with)) { |
|
76 | 76 | $with = func_get_args(); |
77 | 77 | } |
78 | 78 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | public function hasColumn($column) |
179 | 179 | { |
180 | 180 | $table = $this->getModel()->getTable(); |
181 | - $columns = Cache::remember('admin.columns.'.$table, 60, function () use ($table) { |
|
181 | + $columns = Cache::remember('admin.columns.'.$table, 60, function() use ($table) { |
|
182 | 182 | return Schema::getColumnListing($table); |
183 | 183 | }); |
184 | 184 |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @param $id |
204 | 204 | * @param $parentId |
205 | - * @param $left |
|
205 | + * @param integer $left |
|
206 | 206 | * @param $right |
207 | 207 | */ |
208 | 208 | public function move($id, $parentId, $left, $right) |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * Call several methods and get first result. |
292 | 292 | * |
293 | 293 | * @param $instance |
294 | - * @param $methods |
|
294 | + * @param string[] $methods |
|
295 | 295 | * |
296 | 296 | * @return mixed |
297 | 297 | * @throws Exception |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @param $root |
313 | 313 | * @param $parentId |
314 | - * @param $left |
|
314 | + * @param integer $left |
|
315 | 315 | * |
316 | - * @return mixed |
|
316 | + * @return integer |
|
317 | 317 | */ |
318 | 318 | protected function recursiveReorder($root, $parentId, $left) |
319 | 319 | { |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * Recursive reoder simple tree type. |
333 | 333 | * |
334 | 334 | * @param $data |
335 | - * @param $parentId |
|
335 | + * @param string|null $parentId |
|
336 | 336 | */ |
337 | 337 | protected function recursiveReorderSimple($data, $parentId) |
338 | 338 | { |
@@ -354,9 +354,9 @@ discard block |
||
354 | 354 | * Get children for simple tree type structure. |
355 | 355 | * |
356 | 356 | * @param $collection |
357 | - * @param $id |
|
357 | + * @param string|null $id |
|
358 | 358 | * |
359 | - * @return static |
|
359 | + * @return Collection |
|
360 | 360 | */ |
361 | 361 | protected function getChildren($collection, $id) |
362 | 362 | { |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | |
377 | 377 | /** |
378 | 378 | * Create simple tree type structure. |
379 | - * @return static |
|
379 | + * @return Collection |
|
380 | 380 | */ |
381 | 381 | protected function createSimpleTree() |
382 | 382 | { |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | { |
210 | 210 | $instance = $this->find($id); |
211 | 211 | $attributes = $instance->getAttributes(); |
212 | - $attributes[$this->getLeftColumn($instance)] = $left; |
|
213 | - $attributes[$this->getRightColumn($instance)] = $right; |
|
214 | - $attributes[$this->getParentColumn($instance)] = $parentId; |
|
212 | + $attributes[ $this->getLeftColumn($instance) ] = $left; |
|
213 | + $attributes[ $this->getRightColumn($instance) ] = $right; |
|
214 | + $attributes[ $this->getParentColumn($instance) ] = $parentId; |
|
215 | 215 | $instance->setRawAttributes($attributes); |
216 | 216 | $instance->save(); |
217 | 217 | } |
@@ -318,11 +318,11 @@ discard block |
||
318 | 318 | protected function recursiveReorder($root, $parentId, $left) |
319 | 319 | { |
320 | 320 | $right = $left + 1; |
321 | - $children = array_get($root, 'children', []); |
|
321 | + $children = array_get($root, 'children', [ ]); |
|
322 | 322 | foreach ($children as $child) { |
323 | - $right = $this->recursiveReorder($child, $root['id'], $right); |
|
323 | + $right = $this->recursiveReorder($child, $root[ 'id' ], $right); |
|
324 | 324 | } |
325 | - $this->move($root['id'], $parentId, $left, $right); |
|
325 | + $this->move($root[ 'id' ], $parentId, $left, $right); |
|
326 | 326 | $left = $right + 1; |
327 | 327 | |
328 | 328 | return $left; |
@@ -337,15 +337,15 @@ discard block |
||
337 | 337 | protected function recursiveReorderSimple($data, $parentId) |
338 | 338 | { |
339 | 339 | foreach ($data as $order => $item) { |
340 | - $id = $item['id']; |
|
340 | + $id = $item[ 'id' ]; |
|
341 | 341 | |
342 | 342 | $instance = $this->find($id); |
343 | 343 | $instance->{$this->getParentField()} = $parentId; |
344 | 344 | $instance->{$this->getOrderField()} = $order; |
345 | 345 | $instance->save(); |
346 | 346 | |
347 | - if (isset($item['children'])) { |
|
348 | - $this->recursiveReorderSimple($item['children'], $id); |
|
347 | + if (isset($item[ 'children' ])) { |
|
348 | + $this->recursiveReorderSimple($item[ 'children' ], $id); |
|
349 | 349 | } |
350 | 350 | } |
351 | 351 | } |
@@ -361,14 +361,14 @@ discard block |
||
361 | 361 | protected function getChildren($collection, $id) |
362 | 362 | { |
363 | 363 | $parentField = $this->getParentField(); |
364 | - $result = []; |
|
364 | + $result = [ ]; |
|
365 | 365 | foreach ($collection as $instance) { |
366 | 366 | if ($instance->$parentField != $id) { |
367 | 367 | continue; |
368 | 368 | } |
369 | 369 | |
370 | 370 | $instance->setRelation('children', $this->getChildren($collection, $instance->getKey())); |
371 | - $result[] = $instance; |
|
371 | + $result[ ] = $instance; |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | return Collection::make($result); |
@@ -46,7 +46,7 @@ |
||
46 | 46 | /** |
47 | 47 | * Move model in the $destination. |
48 | 48 | * |
49 | - * @param $destination -1 (move down) or 1 (move up) |
|
49 | + * @param integer $destination -1 (move down) or 1 (move up) |
|
50 | 50 | */ |
51 | 51 | protected function move($destination) |
52 | 52 | { |
@@ -9,11 +9,11 @@ |
||
9 | 9 | */ |
10 | 10 | protected static function bootOrderableModel() |
11 | 11 | { |
12 | - static::creating(function ($row) { |
|
12 | + static::creating(function($row) { |
|
13 | 13 | $row->updateOrderFieldOnCreate(); |
14 | 14 | }); |
15 | 15 | |
16 | - static::deleted(function ($row) { |
|
16 | + static::deleted(function($row) { |
|
17 | 17 | $row->updateOrderFieldOnDelete(); |
18 | 18 | }); |
19 | 19 | } |