-
-
Save akoepcke/ecadcaf3bf5f19a777983d23de2068d6 to your computer and use it in GitHub Desktop.
Blade Route Directives
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 | |
// 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