public function filter(Closure $callback)
$this->items = array_filter($this->items, $callback);
return $this;
Otherwise you lose any manipulation you have done previously... Thoughts?
return $voicemails;
$voicemails = $this->request('voicemail_count_url', array(
// code
$voicemails = $voicemails->filter(function($voicemail) {
// code
$voicemails = $voicemails->map(function($voicemail) {
/// code...
return $voicemails;
return $this->request('voicemail_count_url', array(
// code
))->filter(function($voicemail) {
// code
})->map(function($voicemail) {
/// code...
Actually, I think both map()
and filter()
should be kept how they are (for a few reasons, sometimes you want new collections, also backwards compatibility)
However, map()
has a similar function called each()
which works on the current object and does not return a new one. I would suggest we add a similar companion function for filter()
.
https://github.com/laravel/framework/blob/master/src/Illuminate/Support/Collection.php#L158-L180
@Kindari Agreed. Although the descriptions for each()
and map()
should probably be updated to reflect what they actually do.
Maybe filtered()
as the filter()
companion?