Created
May 6, 2015 06:55
-
-
Save trizz/aff0269a7b93d7fffdb0 to your computer and use it in GitHub Desktop.
Show a different Blade template based on permission. If 'private' then look for a template in the 'private' folder inside the original folder with the same name.
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
app('view')->creator('*', function (\Illuminate\Contracts\View\View $view) { | |
if(env('API_CLIENT_ID') === 'private') { | |
$viewValues = explode('/', $view->getPath()); | |
$alreadyPrivate = ($viewValues[count($viewValues) - 2] === 'private'); | |
$last = array_pop($viewValues); | |
array_push($viewValues, 'private', $last); | |
$privateView = implode('/', $viewValues); | |
if (file_exists($privateView) && $alreadyPrivate === false) { | |
$view->setPath($privateView); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment