Last active
June 14, 2020 10:54
-
-
Save kevinruscoe/c8092be648021540773285a176e563b4 to your computer and use it in GitHub Desktop.
A few handy response 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 | |
Request::macro('startsWith', function(string $needle) { | |
return collect(array_filter( | |
$this->all(), | |
fn($key) => str_starts_with($key, $needle), | |
ARRAY_FILTER_USE_KEY | |
)); | |
}); | |
Request::macro('endsWith', function(string $needle) { | |
return collect(array_filter( | |
$this->all(), | |
fn($key) => str_ends_with($key, $needle), | |
ARRAY_FILTER_USE_KEY | |
)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment