@@ -2,8 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace Encore\Admin\Form\Concerns; |
4 | 4 | |
5 | -use Encore\Admin\Form\Field; |
|
6 | - |
|
7 | 5 | trait HandleCascadeFields |
8 | 6 | { |
9 | 7 | /** |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @param string $column |
288 | 288 | * |
289 | - * @return mixed|string |
|
289 | + * @return string |
|
290 | 290 | */ |
291 | 291 | protected function formatColumn($column = '') |
292 | 292 | { |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | } |
600 | 600 | |
601 | 601 | /** |
602 | - * @param string|array|Closure $input |
|
602 | + * @param callable|null $input |
|
603 | 603 | * @param string|array $original |
604 | 604 | * |
605 | 605 | * @return array|Closure |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | /** |
811 | 811 | * Set or get value of the field. |
812 | 812 | * |
813 | - * @param null $value |
|
813 | + * @param string $value |
|
814 | 814 | * |
815 | 815 | * @return mixed |
816 | 816 | */ |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | /** |
982 | 982 | * Add html attributes to elements. |
983 | 983 | * |
984 | - * @param array|string $attribute |
|
984 | + * @param string $attribute |
|
985 | 985 | * @param mixed $value |
986 | 986 | * |
987 | 987 | * @return $this |
@@ -1301,7 +1301,7 @@ discard block |
||
1301 | 1301 | /** |
1302 | 1302 | * Set form group class. |
1303 | 1303 | * |
1304 | - * @param string|array $class |
|
1304 | + * @param string[] $class |
|
1305 | 1305 | * |
1306 | 1306 | * @return $this |
1307 | 1307 | */ |
@@ -1368,7 +1368,7 @@ discard block |
||
1368 | 1368 | } |
1369 | 1369 | |
1370 | 1370 | /** |
1371 | - * @param array $labelClass |
|
1371 | + * @param string[] $labelClass |
|
1372 | 1372 | * |
1373 | 1373 | * @return self |
1374 | 1374 | */ |
@@ -1422,7 +1422,7 @@ discard block |
||
1422 | 1422 | * |
1423 | 1423 | * @param string $view |
1424 | 1424 | * |
1425 | - * @return string |
|
1425 | + * @return Field |
|
1426 | 1426 | */ |
1427 | 1427 | public function setView($view): self |
1428 | 1428 | { |
@@ -100,7 +100,7 @@ |
||
100 | 100 | |
101 | 101 | /** |
102 | 102 | * @param int $group |
103 | - * @return array |
|
103 | + * @return string[] |
|
104 | 104 | * @throws \Exception |
105 | 105 | */ |
106 | 106 | protected function getDependentsElementClass(int $group) |
@@ -88,9 +88,9 @@ |
||
88 | 88 | */ |
89 | 89 | protected function applyCascadeConditions() |
90 | 90 | { |
91 | - $this->form->fields()->filter(function (Form\Field $field) { |
|
91 | + $this->form->fields()->filter(function(Form\Field $field) { |
|
92 | 92 | return $field->isDependsOn($this); |
93 | - })->each(function (Form\Field $field) { |
|
93 | + })->each(function(Form\Field $field) { |
|
94 | 94 | $group = Arr::get($field->getDependency(), 'group'); |
95 | 95 | $field->setGroupClass( |
96 | 96 | $this->getDependentsElementClass($group) |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | return $ret; |
252 | 252 | } |
253 | 253 | |
254 | - collect(explode(',', $id))->filter()->each(function ($id) { |
|
254 | + collect(explode(',', $id))->filter()->each(function($id) { |
|
255 | 255 | $builder = $this->model()->newQuery(); |
256 | 256 | |
257 | 257 | if ($this->isSoftDeletes) { |
@@ -304,9 +304,9 @@ discard block |
||
304 | 304 | |
305 | 305 | $data = $model->toArray(); |
306 | 306 | |
307 | - $this->fields()->filter(function ($field) { |
|
307 | + $this->fields()->filter(function($field) { |
|
308 | 308 | return $field instanceof Field\File; |
309 | - })->each(function (Field\File $file) use ($data) { |
|
309 | + })->each(function(Field\File $file) use ($data) { |
|
310 | 310 | $file->setOriginal($data); |
311 | 311 | |
312 | 312 | $file->destroy(); |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | return $response; |
332 | 332 | } |
333 | 333 | |
334 | - DB::transaction(function () { |
|
334 | + DB::transaction(function() { |
|
335 | 335 | $inserts = $this->prepareInsert($this->updates); |
336 | 336 | |
337 | 337 | foreach ($inserts as $column => $value) { |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | return $response; |
534 | 534 | } |
535 | 535 | |
536 | - DB::transaction(function () { |
|
536 | + DB::transaction(function() { |
|
537 | 537 | $updates = $this->prepareUpdate($this->updates); |
538 | 538 | |
539 | 539 | foreach ($updates as $column => $value) { |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | protected function getFieldByColumn($column) |
986 | 986 | { |
987 | 987 | return $this->fields()->first( |
988 | - function (Field $field) use ($column) { |
|
988 | + function(Field $field) use ($column) { |
|
989 | 989 | if (is_array($field->column())) { |
990 | 990 | return in_array($column, $field->column()); |
991 | 991 | } |
@@ -1004,7 +1004,7 @@ discard block |
||
1004 | 1004 | { |
1005 | 1005 | $values = $this->model->toArray(); |
1006 | 1006 | |
1007 | - $this->fields()->each(function (Field $field) use ($values) { |
|
1007 | + $this->fields()->each(function(Field $field) use ($values) { |
|
1008 | 1008 | $field->setOriginal($values); |
1009 | 1009 | }); |
1010 | 1010 | } |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | |
1033 | 1033 | $data = $this->model->toArray(); |
1034 | 1034 | |
1035 | - $this->fields()->each(function (Field $field) use ($data) { |
|
1035 | + $this->fields()->each(function(Field $field) use ($data) { |
|
1036 | 1036 | if (!in_array($field->column(), $this->ignored, true)) { |
1037 | 1037 | $field->fill($data); |
1038 | 1038 | } |
@@ -1162,7 +1162,7 @@ discard block |
||
1162 | 1162 | */ |
1163 | 1163 | public function setWidth($fieldWidth = 8, $labelWidth = 2): self |
1164 | 1164 | { |
1165 | - $this->fields()->each(function ($field) use ($fieldWidth, $labelWidth) { |
|
1165 | + $this->fields()->each(function($field) use ($fieldWidth, $labelWidth) { |
|
1166 | 1166 | /* @var Field $field */ |
1167 | 1167 | $field->setWidth($fieldWidth, $labelWidth); |
1168 | 1168 | }); |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public function field($name) |
345 | 345 | { |
346 | - return $this->fields()->first(function (Field $field) use ($name) { |
|
346 | + return $this->fields()->first(function(Field $field) use ($name) { |
|
347 | 347 | return $field->column() === $name; |
348 | 348 | }); |
349 | 349 | } |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | |
574 | 574 | $this->form->getLayout()->removeReservedFields($reservedColumns); |
575 | 575 | |
576 | - $this->fields = $this->fields()->reject(function (Field $field) use ($reservedColumns) { |
|
576 | + $this->fields = $this->fields()->reject(function(Field $field) use ($reservedColumns) { |
|
577 | 577 | return in_array($field->column(), $reservedColumns, true); |
578 | 578 | }); |
579 | 579 | } |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | $tabObj = $this->form->setTab(); |
656 | 656 | |
657 | 657 | if (!$tabObj->isEmpty()) { |
658 | - $this->addTabformScript();; |
|
658 | + $this->addTabformScript(); ; |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | $this->addCascadeScript(); |