Recently Laravel introduced a Tappable trait. This blogpost explains what this trait allows you to do.

As you might know, the Laravel framework comes with a handy tap method which allows you to call the given closure with the given value and then return the value. Sounds confusing? It probably is until you've seen it!

https://protone.media/en/blog/introducting-the-tappable-trait