@@ -31,7 +31,7 @@ |
||
| 31 | 31 | * Generate thumbnail URL. |
| 32 | 32 | * |
| 33 | 33 | * @param $image |
| 34 | - * @param $type |
|
| 34 | + * @param string $type |
|
| 35 | 35 | * |
| 36 | 36 | * @return string |
| 37 | 37 | */ |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | * |
| 55 | 55 | * @param bool $toArray |
| 56 | 56 | * |
| 57 | - * @return array|Collection|mixed |
|
| 57 | + * @return Collection |
|
| 58 | 58 | */ |
| 59 | 59 | public function applyFilter($toArray = true) |
| 60 | 60 | { |
@@ -125,14 +125,14 @@ |
||
| 125 | 125 | */ |
| 126 | 126 | protected function parseQueryBindings(array $queries) |
| 127 | 127 | { |
| 128 | - $columnMap = $this->columns->mapWithKeys(function (Column $column) { |
|
| 128 | + $columnMap = $this->columns->mapWithKeys(function(Column $column) { |
|
| 129 | 129 | $label = $column->getLabel(); |
| 130 | 130 | $name = $column->getName(); |
| 131 | 131 | |
| 132 | 132 | return [$label => $name, $name => $name]; |
| 133 | 133 | }); |
| 134 | 134 | |
| 135 | - return collect($queries)->map(function ($query) use ($columnMap) { |
|
| 135 | + return collect($queries)->map(function($query) use ($columnMap) { |
|
| 136 | 136 | $segments = explode(':', $query, 2); |
| 137 | 137 | |
| 138 | 138 | if (count($segments) != 2) { |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | /** |
| 167 | 167 | * Extend column displayer. |
| 168 | 168 | * |
| 169 | - * @param $name |
|
| 169 | + * @param string $name |
|
| 170 | 170 | * @param $displayer |
| 171 | 171 | */ |
| 172 | 172 | public static function extend($name, $displayer) |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | /** |
| 201 | 201 | * Set model for column. |
| 202 | 202 | * |
| 203 | - * @param $model |
|
| 203 | + * @param Model $model |
|
| 204 | 204 | */ |
| 205 | 205 | public function setModel($model) |
| 206 | 206 | { |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | /** |
| 285 | 285 | * Get original column value. |
| 286 | 286 | * |
| 287 | - * @return mixed |
|
| 287 | + * @return string |
|
| 288 | 288 | */ |
| 289 | 289 | public function getOriginal() |
| 290 | 290 | { |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | /** |
| 295 | 295 | * Get name of this column. |
| 296 | 296 | * |
| 297 | - * @return mixed |
|
| 297 | + * @return string |
|
| 298 | 298 | */ |
| 299 | 299 | public function getName() |
| 300 | 300 | { |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | /** |
| 323 | 323 | * Get label of the column. |
| 324 | 324 | * |
| 325 | - * @return mixed |
|
| 325 | + * @return string |
|
| 326 | 326 | */ |
| 327 | 327 | public function getLabel() |
| 328 | 328 | { |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | * Display using display abstract. |
| 410 | 410 | * |
| 411 | 411 | * @param string $abstract |
| 412 | - * @param array $arguments |
|
| 412 | + * @param Closure[] $arguments |
|
| 413 | 413 | * |
| 414 | 414 | * @return $this |
| 415 | 415 | */ |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | |
| 420 | 420 | $column = $this; |
| 421 | 421 | |
| 422 | - return $this->display(function ($value) use ($grid, $column, $abstract, $arguments) { |
|
| 422 | + return $this->display(function($value) use ($grid, $column, $abstract, $arguments) { |
|
| 423 | 423 | /** @var AbstractDisplayer $displayer */ |
| 424 | 424 | $displayer = new $abstract($value, $grid, $column, $this); |
| 425 | 425 | |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | */ |
| 438 | 438 | public function using(array $values, $default = null) |
| 439 | 439 | { |
| 440 | - return $this->display(function ($value) use ($values, $default) { |
|
| 440 | + return $this->display(function($value) use ($values, $default) { |
|
| 441 | 441 | if (is_null($value)) { |
| 442 | 442 | return $default; |
| 443 | 443 | } |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | */ |
| 456 | 456 | public function replace(array $replacements) |
| 457 | 457 | { |
| 458 | - return $this->display(function ($value) use ($replacements) { |
|
| 458 | + return $this->display(function($value) use ($replacements) { |
|
| 459 | 459 | if (isset($replacements[$value])) { |
| 460 | 460 | return $replacements[$value]; |
| 461 | 461 | } |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | */ |
| 474 | 474 | public function view($view) |
| 475 | 475 | { |
| 476 | - return $this->display(function ($value) use ($view) { |
|
| 476 | + return $this->display(function($value) use ($view) { |
|
| 477 | 477 | $model = $this; |
| 478 | 478 | |
| 479 | 479 | return view($view, compact('model', 'value'))->render(); |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | */ |
| 514 | 514 | public function filesize() |
| 515 | 515 | { |
| 516 | - return $this->display(function ($value) { |
|
| 516 | + return $this->display(function($value) { |
|
| 517 | 517 | return file_size($value); |
| 518 | 518 | }); |
| 519 | 519 | } |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | */ |
| 528 | 528 | public function gravatar($size = 30) |
| 529 | 529 | { |
| 530 | - return $this->display(function ($value) use ($size) { |
|
| 530 | + return $this->display(function($value) use ($size) { |
|
| 531 | 531 | $src = sprintf( |
| 532 | 532 | 'https://www.gravatar.com/avatar/%s?s=%d', |
| 533 | 533 | md5(strtolower($value)), |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | */ |
| 549 | 549 | public function loading($values = [], $others = []) |
| 550 | 550 | { |
| 551 | - return $this->display(function ($value) use ($values, $others) { |
|
| 551 | + return $this->display(function($value) use ($values, $others) { |
|
| 552 | 552 | $values = (array) $values; |
| 553 | 553 | |
| 554 | 554 | if (in_array($value, $values)) { |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | */ |
| 570 | 570 | public function icon(array $setting, $default = '') |
| 571 | 571 | { |
| 572 | - return $this->display(function ($value) use ($setting, $default) { |
|
| 572 | + return $this->display(function($value) use ($setting, $default) { |
|
| 573 | 573 | $fa = ''; |
| 574 | 574 | |
| 575 | 575 | if (isset($setting[$value])) { |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | Carbon::setLocale($locale); |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | - return $this->display(function ($value) { |
|
| 598 | + return $this->display(function($value) { |
|
| 599 | 599 | return Carbon::parse($value)->diffForHumans(); |
| 600 | 600 | }); |
| 601 | 601 | } |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | $grid = $this->grid; |
| 717 | 717 | $column = $this; |
| 718 | 718 | |
| 719 | - $this->display(function ($value) use ($grid, $column, $class) { |
|
| 719 | + $this->display(function($value) use ($grid, $column, $class) { |
|
| 720 | 720 | /** @var AbstractDisplayer $definition */ |
| 721 | 721 | $definition = new $class($value, $grid, $column, $this); |
| 722 | 722 | |
@@ -734,7 +734,7 @@ discard block |
||
| 734 | 734 | protected function htmlEntityEncode($item) |
| 735 | 735 | { |
| 736 | 736 | if (is_array($item)) { |
| 737 | - array_walk_recursive($item, function (&$value) { |
|
| 737 | + array_walk_recursive($item, function(&$value) { |
|
| 738 | 738 | $value = htmlentities($value); |
| 739 | 739 | }); |
| 740 | 740 | } else { |
@@ -822,7 +822,7 @@ discard block |
||
| 822 | 822 | 'content' => $this->help, |
| 823 | 823 | ]; |
| 824 | 824 | |
| 825 | - $data = collect($data)->map(function ($val, $key) { |
|
| 825 | + $data = collect($data)->map(function($val, $key) { |
|
| 826 | 826 | return "data-{$key}=\"{$val}\""; |
| 827 | 827 | })->implode(' '); |
| 828 | 828 | |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | */ |
| 861 | 861 | protected function callSupportDisplayer($abstract, $arguments) |
| 862 | 862 | { |
| 863 | - return $this->display(function ($value) use ($abstract, $arguments) { |
|
| 863 | + return $this->display(function($value) use ($abstract, $arguments) { |
|
| 864 | 864 | if (is_array($value) || $value instanceof Arrayable) { |
| 865 | 865 | return call_user_func_array([collect($value), $abstract], $arguments); |
| 866 | 866 | } |
@@ -884,7 +884,7 @@ discard block |
||
| 884 | 884 | protected function callBuiltinDisplayer($abstract, $arguments) |
| 885 | 885 | { |
| 886 | 886 | if ($abstract instanceof Closure) { |
| 887 | - return $this->display(function ($value) use ($abstract, $arguments) { |
|
| 887 | + return $this->display(function($value) use ($abstract, $arguments) { |
|
| 888 | 888 | return $abstract->call($this, ...array_merge([$value], $arguments)); |
| 889 | 889 | }); |
| 890 | 890 | } |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | $grid = $this->grid; |
| 894 | 894 | $column = $this; |
| 895 | 895 | |
| 896 | - return $this->display(function ($value) use ($abstract, $grid, $column, $arguments) { |
|
| 896 | + return $this->display(function($value) use ($abstract, $grid, $column, $arguments) { |
|
| 897 | 897 | /** @var AbstractDisplayer $displayer */ |
| 898 | 898 | $displayer = new $abstract($value, $grid, $column, $this); |
| 899 | 899 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | $show = $this->grid->visibleColumnNames(); |
| 48 | 48 | |
| 49 | - $lists = $this->getGridColumns()->map(function ($label, $key) use ($show) { |
|
| 49 | + $lists = $this->getGridColumns()->map(function($label, $key) use ($show) { |
|
| 50 | 50 | if (empty($show)) { |
| 51 | 51 | $checked = 'checked'; |
| 52 | 52 | } else { |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | protected function getGridColumns() |
| 100 | 100 | { |
| 101 | - return $this->grid->columns()->map(function (Grid\Column $column) { |
|
| 101 | + return $this->grid->columns()->map(function(Grid\Column $column) { |
|
| 102 | 102 | $name = $column->getName(); |
| 103 | 103 | |
| 104 | 104 | if ($this->isColumnIgnored($name)) { |
@@ -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 | $style = Arr::get($style, $this->getColumn()->getOriginal(), 'success'); |
| 19 | 19 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | $this->value = $this->value->toArray(); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - return collect((array) $this->value)->map(function ($name) use ($style) { |
|
| 16 | + return collect((array) $this->value)->map(function($name) use ($style) { |
|
| 17 | 17 | if (is_array($style)) { |
| 18 | 18 | $style = Arr::get($style, $this->getColumn()->getOriginal(), 'red'); |
| 19 | 19 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | $this->value = $this->value->toArray(); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - return collect((array) $this->value)->filter()->map(function ($value) use ($server) { |
|
| 16 | + return collect((array) $this->value)->filter()->map(function($value) use ($server) { |
|
| 17 | 17 | if (empty($value)) { |
| 18 | 18 | return ''; |
| 19 | 19 | } |
@@ -111,6 +111,9 @@ discard block |
||
| 111 | 111 | ]; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | + /** |
|
| 115 | + * @param string $permission |
|
| 116 | + */ |
|
| 114 | 117 | private function generateHttpMethod($permission) |
| 115 | 118 | { |
| 116 | 119 | switch ($permission) { |
@@ -132,6 +135,9 @@ discard block |
||
| 132 | 135 | return $http_method; |
| 133 | 136 | } |
| 134 | 137 | |
| 138 | + /** |
|
| 139 | + * @param string $permission |
|
| 140 | + */ |
|
| 135 | 141 | private function generateHttpPath($table, $permission) |
| 136 | 142 | { |
| 137 | 143 | $resource = Str::kebab(Str::camel($table)); |
@@ -158,6 +164,9 @@ discard block |
||
| 158 | 164 | return $http_path; |
| 159 | 165 | } |
| 160 | 166 | |
| 167 | + /** |
|
| 168 | + * @param string $permission |
|
| 169 | + */ |
|
| 161 | 170 | private function generateSlug($table, $permission) |
| 162 | 171 | { |
| 163 | 172 | return Str::kebab(Str::camel($table)) . '.' . $permission; |
@@ -137,19 +137,19 @@ discard block |
||
| 137 | 137 | $resource = Str::kebab(Str::camel($table)); |
| 138 | 138 | switch ($permission) { |
| 139 | 139 | case 'create': |
| 140 | - $http_path = '/' . $resource; |
|
| 140 | + $http_path = '/'.$resource; |
|
| 141 | 141 | break; |
| 142 | 142 | case 'edit': |
| 143 | - $http_path = '/' . $resource . '/*'; |
|
| 143 | + $http_path = '/'.$resource.'/*'; |
|
| 144 | 144 | break; |
| 145 | 145 | case 'delete': |
| 146 | - $http_path = '/' . $resource . '/*'; |
|
| 146 | + $http_path = '/'.$resource.'/*'; |
|
| 147 | 147 | break; |
| 148 | 148 | case 'index': |
| 149 | - $http_path = '/' . $resource; |
|
| 149 | + $http_path = '/'.$resource; |
|
| 150 | 150 | break; |
| 151 | 151 | case 'view': |
| 152 | - $http_path = '/' . $resource . '/*'; |
|
| 152 | + $http_path = '/'.$resource.'/*'; |
|
| 153 | 153 | break; |
| 154 | 154 | default: |
| 155 | 155 | $http_path = ''; |
@@ -160,11 +160,11 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | private function generateSlug($table, $permission) |
| 162 | 162 | { |
| 163 | - return Str::kebab(Str::camel($table)) . '.' . $permission; |
|
| 163 | + return Str::kebab(Str::camel($table)).'.'.$permission; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | private function generateName($table, $permission_zh) |
| 167 | 167 | { |
| 168 | - return Str::upper(Str::kebab(Str::camel($table))) . $permission_zh; |
|
| 168 | + return Str::upper(Str::kebab(Str::camel($table))).$permission_zh; |
|
| 169 | 169 | } |
| 170 | 170 | } |