Skip to content

Commit d5cdc09

Browse files
Merge pull request spatie#486 from lartisan/main
Add last() method on DataCollection
2 parents c89bb58 + f49f784 commit d5cdc09

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Concerns/EnumerableMethods.php

+13
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@ public function first(callable|null $callback = null, $default = null)
6565
return $this->items->first($callback, $default);
6666
}
6767

68+
/**
69+
* @template TLastDefault
70+
*
71+
* @param null| (callable(TValue,TKey): bool) $callback
72+
* @param TLastDefault|(\Closure(): TLastDefault) $default
73+
*
74+
* @return TValue|TLastDefault
75+
*/
76+
public function last(callable|null $callback = null, $default = null)
77+
{
78+
return $this->items->last($callback, $default);
79+
}
80+
6881
/**
6982
* @param callable(TValue, TKey): mixed $callback
7083
*

0 commit comments

Comments
 (0)