© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago
Josemi

How to refactor an action?

Hi all. I am trying to make a refactor a custom action like :

class BorrowAction extends Action
{
protected ?Article $article;
protected ?int $user_id;

public function setArticle(Article | Closure $article): static
{
$this->article = $this->evaluate($article);
clock($this->article->id);
return $this;
}


And use it like:
BorrowAction::make('borrow')
->setArticle(function (Article $article) {
return $article;
})


But the Model injection on the Closure don't work. Why is that?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to trigger an action from another action?
FilamentFFilament / ❓┊help
14mo ago
How to close an ActionGroup dropdown with a custom action function
FilamentFFilament / ❓┊help
3y ago
How to dispatch an event from an Action
FilamentFFilament / ❓┊help
16mo ago
Form actions must be an instance of Filament\Actions\Action, or Filament\Actions\ActionGroup.
FilamentFFilament / ❓┊help
3y ago