@@ -13,7 +13,7 @@ |
||
13 | 13 | $this->value = $this->value->toArray(); |
14 | 14 | } |
15 | 15 | |
16 | - return collect((array) $this->value)->map(function ($item) use ($style) { |
|
16 | + return collect((array) $this->value)->map(function($item) use ($style) { |
|
17 | 17 | if (is_array($style)) { |
18 | 18 | $columnValue = $this->getColumn()->getOriginal(); |
19 | 19 |
@@ -157,16 +157,16 @@ discard block |
||
157 | 157 | call_user_func($this->callback, $this); |
158 | 158 | } |
159 | 159 | |
160 | - $response = function () { |
|
160 | + $response = function() { |
|
161 | 161 | $handle = fopen('php://output', 'w'); |
162 | 162 | $titles = []; |
163 | 163 | fwrite($handle, chr(0xEF).chr(0xBB).chr(0xBF)); //导出的CSV文件是无BOM编码UTF-8,而我们通常使用UTF-8编码格式都是有BOM的。所以添加BOM于CSV中 |
164 | - $this->chunk(function ($collection) use ($handle, &$titles) { |
|
164 | + $this->chunk(function($collection) use ($handle, &$titles) { |
|
165 | 165 | Column::setOriginalGridModels($collection); |
166 | 166 | |
167 | 167 | $original = $current = $collection->toArray(); |
168 | 168 | |
169 | - $this->grid->getColumns()->map(function (Column $column) use (&$current) { |
|
169 | + $this->grid->getColumns()->map(function(Column $column) use (&$current) { |
|
170 | 170 | $current = $column->fill($current); |
171 | 171 | $this->grid->columnNames[] = $column->getName(); |
172 | 172 | }); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | protected function getVisiableTitles() |
196 | 196 | { |
197 | 197 | $titles = $this->grid->visibleColumns() |
198 | - ->mapWithKeys(function (Column $column) { |
|
198 | + ->mapWithKeys(function(Column $column) { |
|
199 | 199 | $columnName = $column->getName(); |
200 | 200 | $columnTitle = $column->getLabel(); |
201 | 201 | if (isset($this->titleCallbacks[$columnName])) { |
@@ -325,9 +325,9 @@ discard block |
||
325 | 325 | |
326 | 326 | $this->setSort(); |
327 | 327 | |
328 | - $this->queries->reject(function ($query) { |
|
328 | + $this->queries->reject(function($query) { |
|
329 | 329 | return $query['method'] == 'paginate'; |
330 | - })->each(function ($query) { |
|
330 | + })->each(function($query) { |
|
331 | 331 | $this->model = $this->model->{$query['method']}(...$query['arguments']); |
332 | 332 | }); |
333 | 333 | |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | $this->setSort(); |
379 | 379 | $this->setPaginate(); |
380 | 380 | |
381 | - $this->queries->unique()->each(function ($query) { |
|
381 | + $this->queries->unique()->each(function($query) { |
|
382 | 382 | $this->model = call_user_func_array([$this->model, $query['method']], $query['arguments']); |
383 | 383 | }); |
384 | 384 | |
@@ -408,9 +408,9 @@ discard block |
||
408 | 408 | |
409 | 409 | $queryBuilder = $this->originalModel; |
410 | 410 | |
411 | - $this->queries->reject(function ($query) { |
|
411 | + $this->queries->reject(function($query) { |
|
412 | 412 | return in_array($query['method'], ['get', 'paginate']); |
413 | - })->each(function ($query) use (&$queryBuilder) { |
|
413 | + })->each(function($query) use (&$queryBuilder) { |
|
414 | 414 | $queryBuilder = $queryBuilder->{$query['method']}(...$query['arguments']); |
415 | 415 | }); |
416 | 416 | |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | { |
445 | 445 | $paginate = $this->findQueryByMethod('paginate'); |
446 | 446 | |
447 | - $this->queries = $this->queries->reject(function ($query) { |
|
447 | + $this->queries = $this->queries->reject(function($query) { |
|
448 | 448 | return $query['method'] == 'paginate'; |
449 | 449 | }); |
450 | 450 | |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | */ |
503 | 503 | protected function findQueryByMethod($method) |
504 | 504 | { |
505 | - return $this->queries->first(function ($query) use ($method) { |
|
505 | + return $this->queries->first(function($query) use ($method) { |
|
506 | 506 | return $query['method'] == $method; |
507 | 507 | }); |
508 | 508 | } |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | } |
526 | 526 | |
527 | 527 | $columnNameContainsDots = Str::contains($columnName, '.'); |
528 | - $isRelation = $this->queries->contains(function ($query) use ($columnName) { |
|
528 | + $isRelation = $this->queries->contains(function($query) use ($columnName) { |
|
529 | 529 | // relationship should be camel case |
530 | 530 | $columnName = Str::camel(Str::before($columnName, '.')); |
531 | 531 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | // relationship should be camel case |
577 | 577 | $relationName = Str::camel($relationName); |
578 | 578 | |
579 | - if ($this->queries->contains(function ($query) use ($relationName) { |
|
579 | + if ($this->queries->contains(function($query) use ($relationName) { |
|
580 | 580 | return $query['method'] == 'with' && in_array($relationName, $query['arguments']); |
581 | 581 | })) { |
582 | 582 | $relation = $this->model->$relationName(); |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | */ |
611 | 611 | public function resetOrderBy() |
612 | 612 | { |
613 | - $this->queries = $this->queries->reject(function ($query) { |
|
613 | + $this->queries = $this->queries->reject(function($query) { |
|
614 | 614 | return $query['method'] == 'orderBy' || $query['method'] == 'orderByDesc'; |
615 | 615 | }); |
616 | 616 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function using(array $values, $default = null) |
194 | 194 | { |
195 | - return $this->as(function ($value) use ($values, $default) { |
|
195 | + return $this->as(function($value) use ($values, $default) { |
|
196 | 196 | if (is_null($value)) { |
197 | 197 | return $default; |
198 | 198 | } |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function image($server = '', $width = 200, $height = 200) |
214 | 214 | { |
215 | - return $this->unescape()->as(function ($images) use ($server, $width, $height) { |
|
216 | - return collect($images)->map(function ($path) use ($server, $width, $height) { |
|
215 | + return $this->unescape()->as(function($images) use ($server, $width, $height) { |
|
216 | + return collect($images)->map(function($path) use ($server, $width, $height) { |
|
217 | 217 | if (empty($path)) { |
218 | 218 | return ''; |
219 | 219 | } |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public function carousel($width = 300, $height = 200, $server = '') |
250 | 250 | { |
251 | - return $this->unescape()->as(function ($images) use ($server, $width, $height) { |
|
252 | - $items = collect($images)->map(function ($path) use ($server, $width, $height) { |
|
251 | + return $this->unescape()->as(function($images) use ($server, $width, $height) { |
|
252 | + $items = collect($images)->map(function($path) use ($server, $width, $height) { |
|
253 | 253 | if (empty($path)) { |
254 | 254 | return ''; |
255 | 255 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | { |
290 | 290 | $field = $this; |
291 | 291 | |
292 | - return $this->unescape()->as(function ($path) use ($server, $download, $field) { |
|
292 | + return $this->unescape()->as(function($path) use ($server, $download, $field) { |
|
293 | 293 | $name = basename($path); |
294 | 294 | |
295 | 295 | $field->border = false; |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public function link($href = '', $target = '_blank') |
345 | 345 | { |
346 | - return $this->unescape()->as(function ($link) use ($href, $target) { |
|
346 | + return $this->unescape()->as(function($link) use ($href, $target) { |
|
347 | 347 | $href = $href ?: $link; |
348 | 348 | |
349 | 349 | return "<a href='$href' target='{$target}'>{$link}</a>"; |
@@ -359,12 +359,12 @@ discard block |
||
359 | 359 | */ |
360 | 360 | public function label($style = 'success') |
361 | 361 | { |
362 | - return $this->unescape()->as(function ($value) use ($style) { |
|
362 | + return $this->unescape()->as(function($value) use ($style) { |
|
363 | 363 | if ($value instanceof Arrayable) { |
364 | 364 | $value = $value->toArray(); |
365 | 365 | } |
366 | 366 | |
367 | - return collect((array) $value)->map(function ($name) use ($style) { |
|
367 | + return collect((array) $value)->map(function($name) use ($style) { |
|
368 | 368 | return "<span class='label label-{$style}'>$name</span>"; |
369 | 369 | })->implode(' '); |
370 | 370 | }); |
@@ -379,12 +379,12 @@ discard block |
||
379 | 379 | */ |
380 | 380 | public function badge($style = 'blue') |
381 | 381 | { |
382 | - return $this->unescape()->as(function ($value) use ($style) { |
|
382 | + return $this->unescape()->as(function($value) use ($style) { |
|
383 | 383 | if ($value instanceof Arrayable) { |
384 | 384 | $value = $value->toArray(); |
385 | 385 | } |
386 | 386 | |
387 | - return collect((array) $value)->map(function ($name) use ($style) { |
|
387 | + return collect((array) $value)->map(function($name) use ($style) { |
|
388 | 388 | return "<span class='badge bg-{$style}'>$name</span>"; |
389 | 389 | })->implode(' '); |
390 | 390 | }); |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | */ |
401 | 401 | public function number($decimals = 0, $decimal_seperator = '.', $thousands_seperator = ',') |
402 | 402 | { |
403 | - return $this->unescape()->as(function ($value) use ($decimals, $decimal_seperator, $thousands_seperator) { |
|
403 | + return $this->unescape()->as(function($value) use ($decimals, $decimal_seperator, $thousands_seperator) { |
|
404 | 404 | return number_format($value, $decimals, $decimal_seperator, $thousands_seperator); |
405 | 405 | }); |
406 | 406 | } |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | { |
415 | 415 | $field = $this; |
416 | 416 | |
417 | - return $this->unescape()->as(function ($value) use ($field) { |
|
417 | + return $this->unescape()->as(function($value) use ($field) { |
|
418 | 418 | if (is_string($value)) { |
419 | 419 | $content = json_decode($value, true); |
420 | 420 | } else { |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | */ |
439 | 439 | public function filesize() |
440 | 440 | { |
441 | - return $this->as(function ($value) { |
|
441 | + return $this->as(function($value) { |
|
442 | 442 | return file_size($value); |
443 | 443 | }); |
444 | 444 | } |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | |
597 | 597 | $field = $this; |
598 | 598 | |
599 | - return $this->as(function ($value) use ($extend, $field, $arguments) { |
|
599 | + return $this->as(function($value) use ($extend, $field, $arguments) { |
|
600 | 600 | if (!$extend->border) { |
601 | 601 | $field->border = false; |
602 | 602 | } |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | public function render() |
656 | 656 | { |
657 | 657 | if ($this->showAs->isNotEmpty()) { |
658 | - $this->showAs->each(function ($callable) { |
|
658 | + $this->showAs->each(function($callable) { |
|
659 | 659 | $this->value = $callable->call( |
660 | 660 | $this->parent->getModel(), |
661 | 661 | $this->value |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | public function handle() |
50 | 50 | { |
51 | 51 | $prefix = config('admin.route.prefix'); |
52 | - $routes = collect($this->router->getRoutes())->filter(function (Route $route) use ($prefix) { |
|
52 | + $routes = collect($this->router->getRoutes())->filter(function(Route $route) use ($prefix) { |
|
53 | 53 | $uri = $route->uri(); |
54 | 54 | // built-in, parameterized and no-GET are ignored |
55 | 55 | return Str::startsWith($uri, "{$prefix}/") |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | && in_array('GET', $route->methods()) |
60 | 60 | && !in_array(substr($route->uri(), strlen("{$prefix}/")), config('admin.menu_exclude')); |
61 | 61 | }) |
62 | - ->map(function (Route $route) use ($prefix) { |
|
62 | + ->map(function(Route $route) use ($prefix) { |
|
63 | 63 | $uri = substr($route->uri(), strlen("{$prefix}/")); |
64 | 64 | |
65 | 65 | return [ |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | $menus = Menu::all()->pluck('title', 'uri'); |
75 | 75 | // exclude exist ones |
76 | - $news = $routes->diffKeys($menus)->map(function ($item, $key) { |
|
76 | + $news = $routes->diffKeys($menus)->map(function($item, $key) { |
|
77 | 77 | return [ |
78 | 78 | 'title' => $item, |
79 | 79 | 'uri' => $key, |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | } else { |
88 | 88 | if ($this->hasOption('dry-run') && $this->option('dry-run')) { |
89 | 89 | $this->line('<info>The following menu items will be created</info>: '); |
90 | - $this->table(['Title', 'Uri'], array_map(function ($item) { |
|
90 | + $this->table(['Title', 'Uri'], array_map(function($item) { |
|
91 | 91 | return [ |
92 | 92 | $item['title'], |
93 | 93 | $item['uri'], |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | return $ret; |
254 | 254 | } |
255 | 255 | |
256 | - collect(explode(',', $id))->filter()->each(function ($id) { |
|
256 | + collect(explode(',', $id))->filter()->each(function($id) { |
|
257 | 257 | $builder = $this->model()->newQuery(); |
258 | 258 | |
259 | 259 | if ($this->isSoftDeletes) { |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | |
307 | 307 | $data = $model->toArray(); |
308 | 308 | |
309 | - $this->fields()->filter(function ($field) { |
|
309 | + $this->fields()->filter(function($field) { |
|
310 | 310 | return $field instanceof Field\File; |
311 | - })->each(function (Field\File $file) use ($data) { |
|
311 | + })->each(function(Field\File $file) use ($data) { |
|
312 | 312 | $file->setOriginal($data); |
313 | 313 | |
314 | 314 | $file->destroy(); |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | return $response; |
334 | 334 | } |
335 | 335 | |
336 | - DB::transaction(function () { |
|
336 | + DB::transaction(function() { |
|
337 | 337 | $inserts = $this->prepareInsert($this->updates); |
338 | 338 | |
339 | 339 | foreach ($inserts as $column => $value) { |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | return $response; |
539 | 539 | } |
540 | 540 | |
541 | - DB::transaction(function () { |
|
541 | + DB::transaction(function() { |
|
542 | 542 | $updates = $this->prepareUpdate($this->updates); |
543 | 543 | |
544 | 544 | foreach ($updates as $column => $value) { |
@@ -602,13 +602,13 @@ discard block |
||
602 | 602 | { |
603 | 603 | if (request('after-save') == 1) { |
604 | 604 | // continue editing |
605 | - $url = rtrim($resourcesPath, '/') . "/{$key}/edit"; |
|
605 | + $url = rtrim($resourcesPath, '/')."/{$key}/edit"; |
|
606 | 606 | } elseif (request('after-save') == 2) { |
607 | 607 | // continue creating |
608 | - $url = rtrim($resourcesPath, '/') . '/create'; |
|
608 | + $url = rtrim($resourcesPath, '/').'/create'; |
|
609 | 609 | } elseif (request('after-save') == 3) { |
610 | 610 | // view resource |
611 | - $url = rtrim($resourcesPath, '/') . "/{$key}"; |
|
611 | + $url = rtrim($resourcesPath, '/')."/{$key}"; |
|
612 | 612 | } else { |
613 | 613 | $url = request(Builder::PREVIOUS_URL_KEY) ?: $resourcesPath; |
614 | 614 | } |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | protected function getFieldByColumn($column) |
1016 | 1016 | { |
1017 | 1017 | return $this->fields()->first( |
1018 | - function (Field $field) use ($column) { |
|
1018 | + function(Field $field) use ($column) { |
|
1019 | 1019 | if (is_array($field->column())) { |
1020 | 1020 | return in_array($column, $field->column()); |
1021 | 1021 | } |
@@ -1034,7 +1034,7 @@ discard block |
||
1034 | 1034 | { |
1035 | 1035 | $values = $this->model->toArray(); |
1036 | 1036 | |
1037 | - $this->fields()->each(function (Field $field) use ($values) { |
|
1037 | + $this->fields()->each(function(Field $field) use ($values) { |
|
1038 | 1038 | $field->setOriginal($values); |
1039 | 1039 | }); |
1040 | 1040 | } |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | { |
1049 | 1049 | $relations = $this->getRelations(); |
1050 | 1050 | |
1051 | - $this->fields()->each(function (Field $field) use ($relations) { |
|
1051 | + $this->fields()->each(function(Field $field) use ($relations) { |
|
1052 | 1052 | if ($field->getSnakeAttributes()) { |
1053 | 1053 | return; |
1054 | 1054 | } |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | |
1091 | 1091 | $data = $this->model->toArray(); |
1092 | 1092 | |
1093 | - $this->fields()->each(function (Field $field) use ($data) { |
|
1093 | + $this->fields()->each(function(Field $field) use ($data) { |
|
1094 | 1094 | if (!in_array($field->column(), $this->ignored, true)) { |
1095 | 1095 | $field->fill($data); |
1096 | 1096 | } |
@@ -1233,7 +1233,7 @@ discard block |
||
1233 | 1233 | */ |
1234 | 1234 | public function setWidth($fieldWidth = 8, $labelWidth = 2): self |
1235 | 1235 | { |
1236 | - $this->fields()->each(function ($field) use ($fieldWidth, $labelWidth) { |
|
1236 | + $this->fields()->each(function($field) use ($fieldWidth, $labelWidth) { |
|
1237 | 1237 | /* @var Field $field */ |
1238 | 1238 | $field->setWidth($fieldWidth, $labelWidth); |
1239 | 1239 | }); |