Created
March 7, 2016 13:43
-
-
Save andyg1/528e6587cacf96e06466 to your computer and use it in GitHub Desktop.
Include a Blade view template only if there is a logged in user. Useful for including/excluding views and/or partials for things like menus, logout buttons, etc
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
/* | |
* Laravel includeIfAuth() function. | |
* | |
* Usage: @includeIfAuth($templateName) | |
*/ | |
\Blade::directive('includeIfAuth', function ($expression) { | |
if(\Auth::check()) { | |
return \Blade::compileString("@include({$expression})"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment