@@ -18,7 +18,6 @@ trait HasEditor
18
18
*
19
19
* @param array|mixed ...$editors
20
20
* @return $this
21
- * @throws \Exception
22
21
* @see https://editor.datatables.net/
23
22
*/
24
23
public function editors (...$ editors ): static
@@ -27,49 +26,30 @@ public function editors(...$editors): static
27
26
$ editors = $ editors [0 ];
28
27
}
29
28
29
+ $ collection = [];
30
30
foreach ($ editors as $ editor ) {
31
- $ this ->editor ($ editor );
31
+ $ collection [] = $ this ->editor ($ editor );
32
32
}
33
33
34
+ $ this ->editors = $ collection ;
35
+
34
36
return $ this ;
35
37
}
36
38
37
39
/**
38
40
* Integrate with DataTables Editor.
39
41
*
40
- * @param Editor $fields
42
+ * @param Editor $editor
41
43
* @return $this
42
- * @throws \Exception
43
44
* @see https://editor.datatables.net/
44
45
*/
45
- public function editor (Editor $ fields ): static
46
+ public function editor (Editor $ editor ): static
46
47
{
47
48
/** @var string $template */
48
49
$ template = $ this ->config ->get ('datatables-html.editor ' , 'datatables::editor ' );
49
50
50
51
$ this ->setTemplate ($ template );
51
52
52
- $ editor = $ this ->newEditor ($ fields );
53
-
54
- $ this ->editors [] = $ editor ;
55
-
56
- return $ this ;
57
- }
58
-
59
- /**
60
- * @param array|Editor $fields
61
- * @return Editor
62
- * @throws \Exception
63
- */
64
- protected function newEditor (Editor |array $ fields ): Editor
65
- {
66
- if ($ fields instanceof Editor) {
67
- $ editor = $ fields ;
68
- } else {
69
- $ editor = new Editor ;
70
- $ editor ->fields ($ fields );
71
- }
72
-
73
53
if (! $ editor ->table ) {
74
54
$ editor ->table ('# ' .$ this ->getTableAttribute ('id ' ));
75
55
}
@@ -78,7 +58,9 @@ protected function newEditor(Editor|array $fields): Editor
78
58
$ editor ->ajax ($ this ->getAjaxUrl ());
79
59
}
80
60
81
- return $ editor ;
61
+ $ this ->editors [] = $ editor ;
62
+
63
+ return $ this ;
82
64
}
83
65
84
66
/**
0 commit comments