Skip to content

Commit

Permalink
feat: add macro in editor builder
Browse files Browse the repository at this point in the history
  • Loading branch information
yajra committed Aug 31, 2024
1 parent 186d220 commit 0e4326f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Html/Editor/Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Illuminate\Support\Arr;
use Illuminate\Support\Fluent;
use Illuminate\Support\Str;
use Illuminate\Support\Traits\Macroable;
use Yajra\DataTables\Html\Editor\Fields\Field;
use Yajra\DataTables\Html\HasAuthorizations;
use Yajra\DataTables\Utilities\Helper;
Expand All @@ -22,7 +24,9 @@
class Editor extends Fluent
{
use HasAuthorizations;
use HasEvents;
use HasEvents, Macroable {
Macroable::__call as macroCall;
}

final public const DISPLAY_LIGHTBOX = 'lightbox';

Expand Down Expand Up @@ -314,4 +318,15 @@ public function hiddenOnEdit(array $fields): static
{
return $this->hiddenOn('edit', $fields);
}

public function __call($method, $parameters): mixed
{
if (Str::startsWith($method, 'on')) {
$event = Str::camel(substr($method, 2, strlen($method) - 2));

return $this->on($event, $parameters[0]);
}

return $this->macroCall($method, $parameters);

Check failure on line 330 in src/Html/Editor/Editor.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (8.3, prefer-stable)

Method Yajra\DataTables\Html\Editor\Editor::__call() should return $this(Yajra\DataTables\Html\Editor\Editor) but returns mixed.

Check failure on line 330 in src/Html/Editor/Editor.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (8.2, prefer-stable)

Method Yajra\DataTables\Html\Editor\Editor::__call() should return $this(Yajra\DataTables\Html\Editor\Editor) but returns mixed.

Check failure on line 330 in src/Html/Editor/Editor.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (8.3, prefer-stable)

Method Yajra\DataTables\Html\Editor\Editor::__call() should return $this(Yajra\DataTables\Html\Editor\Editor) but returns mixed.
}
}

0 comments on commit 0e4326f

Please sign in to comment.