jossemii
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?
1 replies