mirror of
https://github.com/filamentphp/filament.git
synced 2026-10-24 23:35:30 +08:00
Update InteractsWithActions.php
This commit is contained in:
@@ -273,9 +273,7 @@ trait InteractsWithActions
|
||||
$name = $firstName;
|
||||
}
|
||||
|
||||
$action = $this->cachedActions[$name] ?? null;
|
||||
|
||||
if ($action) {
|
||||
if ($action = $this->cachedActions[$name] ?? null) {
|
||||
return $this->getMountableModalActionFromAction(
|
||||
$action,
|
||||
modalActionNames: $modalActionNames ?? [],
|
||||
@@ -283,17 +281,24 @@ trait InteractsWithActions
|
||||
);
|
||||
}
|
||||
|
||||
if (! method_exists($this, $name)) {
|
||||
if (
|
||||
(! str($name)->endsWith('Action')) &&
|
||||
method_exists($this, "{$name}Action")
|
||||
) {
|
||||
$methodName = "{$name}Action";
|
||||
} elseif (method_exists($this, $name)) {
|
||||
$methodName = $name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
$action = Action::configureUsing(
|
||||
Closure::fromCallable([$this, 'configureAction']),
|
||||
fn () => $this->{$name}(),
|
||||
fn () => $this->{$methodName}(),
|
||||
);
|
||||
|
||||
if (! $action instanceof Action) {
|
||||
throw new InvalidArgumentException('Actions must be an instance of ' . Action::class . ". The [{$name}] method on the Livewire component returned an instance of [" . get_class($action) . '].');
|
||||
throw new InvalidArgumentException('Actions must be an instance of ' . Action::class . ". The [{$methodName}] method on the Livewire component returned an instance of [" . get_class($action) . '].');
|
||||
}
|
||||
|
||||
return $this->getMountableModalActionFromAction(
|
||||
|
||||
Reference in New Issue
Block a user