File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 44
55use Illuminate \Support \Arr ;
66use Illuminate \Support \Fluent ;
7+ use Illuminate \Support \Str ;
8+ use Illuminate \Support \Traits \Macroable ;
79use Yajra \DataTables \Html \Editor \Fields \Field ;
810use Yajra \DataTables \Html \HasAuthorizations ;
911use Yajra \DataTables \Utilities \Helper ;
2224class Editor extends Fluent
2325{
2426 use HasAuthorizations;
25- use HasEvents;
27+ use HasEvents, Macroable {
28+ Macroable::__call as macroCall;
29+ }
2630
2731 final public const DISPLAY_LIGHTBOX = 'lightbox ' ;
2832
@@ -314,4 +318,21 @@ public function hiddenOnEdit(array $fields): static
314318 {
315319 return $ this ->hiddenOn ('edit ' , $ fields );
316320 }
321+
322+ public function __call ($ method , $ parameters ): static
323+ {
324+ if (Str::startsWith ($ method , 'on ' )) {
325+ $ event = Str::camel (substr ($ method , 2 , strlen ($ method ) - 2 ));
326+
327+ return $ this ->on ($ event , $ parameters [0 ]);
328+ }
329+
330+ $ macroCall = $ this ->macroCall ($ method , $ parameters );
331+
332+ if (! $ macroCall instanceof Editor) {
333+ abort (500 , sprintf ('Method %s::%s must return an Editor instance. ' , static ::class, $ method ));
334+ }
335+
336+ return $ this ;
337+ }
317338}
You can’t perform that action at this time.
0 commit comments