Laravel 5.4 – Higher Order Messaging For Collections

Check out the original article.

Two words: HELL, YES

The best way of showcasing this new feature is through code samples. Pretend you have a collection and you want to perform an operation on each of the items:

$invoices->each(function($invoice) {
  $invoice->pay();
});

With this new feature you will be able to simplify this into:

$invoices->each->pay();

via Laravel News