src/Services/Collection.php
public function last(callable $callback = null, $default = null)
    {
        if (is_null($callback)) {
            if (!empty($this->items)) {
                return end($this->items);
            }
        }
        else {
            foreach (array_reverse($this->items, true) as $key => $value) {
                if (call_user_func($callback, $value, $key)) {
                    return $value;
                }
            }
        }

        return $default instanceof Closure ? $default() : $default;
    }
public function last(callable $callback = null, $default = null)
    {
        if (is_null($callback)) {
            if (!empty($this->items)) {
                return end($this->items);
            }
        }
        else {
            foreach (array_reverse($this->items, true) as $key => $value) {
                if (call_user_func($callback, $value, $key)) {
                    return $value;
                }
            }
        }

        return $default instanceof Closure ? $default() : $default;
    }
public function last ( callable $ callback = null , $ default = null ) { if ( is_null ( $ callback ) ) { if ( ! empty ( $ this -> items ) ) { return end ( $ this -> items ) ; } } else { foreach ( array_reverse ( $ this -> items , true ) as $ key => $ value ) { if ( call_user_func ( $ callback , $ value , $ key ) ) { return $ value ; } } } return $ default instanceof Closure ? $ default ( ) : $ default ; }
Get the last item from the collection.

@param  callable|null  $callback
@param  mixed  $default
@return mixed
Get the last item from the collection .