Skip to content

Commit 0e4326f

Browse files
committed
feat: add macro in editor builder
1 parent 186d220 commit 0e4326f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/Html/Editor/Editor.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use Illuminate\Support\Arr;
66
use Illuminate\Support\Fluent;
7+
use Illuminate\Support\Str;
8+
use Illuminate\Support\Traits\Macroable;
79
use Yajra\DataTables\Html\Editor\Fields\Field;
810
use Yajra\DataTables\Html\HasAuthorizations;
911
use Yajra\DataTables\Utilities\Helper;
@@ -22,7 +24,9 @@
2224
class 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,15 @@ public function hiddenOnEdit(array $fields): static
314318
{
315319
return $this->hiddenOn('edit', $fields);
316320
}
321+
322+
public function __call($method, $parameters): mixed
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+
return $this->macroCall($method, $parameters);
331+
}
317332
}

0 commit comments

Comments
 (0)