Created
January 25, 2017 12:24
-
-
Save jleonardolemos/75a8d2d17a278a0f31ece05a38eb562a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uma maneira de definir scopes com HighOrderCollection na a collection