Reuse macro callbacks for multiple classes
Is there a way of extracting the anonoymous functions to a class function? I would like it so I can just pass
$this->onlyForAdmins
, or [$this, 'onlyForAdmins']
and not have to duplicate the func body every time.
I tried to just extract it like I mentioned, but it complains that $this->visible()
is not a method on the class. Is this a Laravel macro thing?Solution:Jump to solution
Found you can just macro a more general class
ViewComponent
that's inherited by Field, Column, Entry etc. Not perfect but it'll work.1 Reply
Solution
Found you can just macro a more general class
ViewComponent
that's inherited by Field, Column, Entry etc. Not perfect but it'll work.