Created
July 30, 2016 10:48
-
-
Save martinbean/2712815d649c2c95a3cc87e46ac75e3e to your computer and use it in GitHub Desktop.
Laravel Request startsWith and endsWith macros
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
<?php | |
use Illuminate\Support\Facades\Request; | |
use Illuminate\Support\Str; | |
Request::macro('startsWith', function () { | |
return Str::startsWith(func_get_args()); | |
}); | |
Request::macro('endsWith', function () { | |
return Str::endsWith(func_get_args()); | |
}); |
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
<?php | |
$isNewsSection = Request::startsWith('news'); | |
$isRssRequest = Request::endsWith('.rss'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can add these macros to a service provider.