Laravel Collection Public API: last
The last method in Laravel's Collection class is used to retrieve the last item in a collection or the last item that matches a specified condition. It takes an optional callback function ($callback) to perform the truth test, and a default value argument ($default) to return when no matching items are found. If the collection is empty, null is returned,...