-
-
Save adamhut/4c9b3202e0d40aa674afc183ef1d778e to your computer and use it in GitHub Desktop.
Blade Route Directives
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 | |
// Register these inside a service provider: | |
Blade::directive('route', function ($expression) { | |
return "<?php echo route({$expression}) ?>"; | |
}); | |
Blade::directive('routeIs', function ($expression) { | |
return "<?php if (request()->routeIs({$expression})) : ?>"; | |
}); | |
Blade::directive('endrouteIs', function () { | |
return "<?php endif; ?>"; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment