@@ -18,7 +18,6 @@ trait HasEditor
1818 *
1919 * @param array|mixed ...$editors
2020 * @return $this
21- * @throws \Exception
2221 * @see https://editor.datatables.net/
2322 */
2423 public function editors (...$ editors ): static
@@ -27,49 +26,30 @@ public function editors(...$editors): static
2726 $ editors = $ editors [0 ];
2827 }
2928
29+ $ collection = [];
3030 foreach ($ editors as $ editor ) {
31- $ this ->editor ($ editor );
31+ $ collection [] = $ this ->editor ($ editor );
3232 }
3333
34+ $ this ->editors = $ collection ;
35+
3436 return $ this ;
3537 }
3638
3739 /**
3840 * Integrate with DataTables Editor.
3941 *
40- * @param Editor $fields
42+ * @param Editor $editor
4143 * @return $this
42- * @throws \Exception
4344 * @see https://editor.datatables.net/
4445 */
45- public function editor (Editor $ fields ): static
46+ public function editor (Editor $ editor ): static
4647 {
4748 /** @var string $template */
4849 $ template = $ this ->config ->get ('datatables-html.editor ' , 'datatables::editor ' );
4950
5051 $ this ->setTemplate ($ template );
5152
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-
7353 if (! $ editor ->table ) {
7454 $ editor ->table ('# ' .$ this ->getTableAttribute ('id ' ));
7555 }
@@ -78,7 +58,9 @@ protected function newEditor(Editor|array $fields): Editor
7858 $ editor ->ajax ($ this ->getAjaxUrl ());
7959 }
8060
81- return $ editor ;
61+ $ this ->editors [] = $ editor ;
62+
63+ return $ this ;
8264 }
8365
8466 /**
0 commit comments