Skip to content

Instantly share code, notes, and snippets.

@jleonardolemos
Created January 25, 2017 12:24
Show Gist options
  • Save jleonardolemos/75a8d2d17a278a0f31ece05a38eb562a to your computer and use it in GitHub Desktop.
Save jleonardolemos/75a8d2d17a278a0f31ece05a38eb562a to your computer and use it in GitHub Desktop.
$collection = App\Post::all();
$collection->macro('withBody', function(callable $callback){
foreach ($this->items as $key => $item) {
if (!$item->body) {
continue;
}
if ($callback($item, $key) === false) {
break;
}
}
return $this;
});
$collection->proxy('withBody');
$collection->withBody->touch();
dd($collection);
@jleonardolemos
Copy link
Author

Uma maneira de definir scopes com HighOrderCollection na a collection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment