Created
March 22, 2019 17:54
-
-
Save mustafaaloko/a4c7cfc533d6e6664bf594437be0292e to your computer and use it in GitHub Desktop.
Macro in AppServiceProvider
This file contains hidden or 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
| <?php | |
| namespace App\Providers; | |
| use Illuminate\Support\ServiceProvider; | |
| use Illuminate\Support\Collection; | |
| class AppServiceProvider extends ServiceProvider | |
| { | |
| /** | |
| * Register any application services. | |
| * | |
| * @return void | |
| */ | |
| public function register() | |
| { | |
| Collection::macro('evens', function() { | |
| return $this->filter(function($value) { | |
| return $value % 2 === 0; | |
| }); | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment