Add blade directive @guest#20114
Conversation
|
If do not pass a guard, will this work? |
|
@it-can Yes |
|
@LKDevelopment That'd be confusing. I'd suggest keeping both PR's as-is, as making the @guest directive work as an else would be confusing if you only want to use guest... |
|
@LKDevelopment If I add a custom directive to my laravel 5.4 app, I get a error when calling AppServiceProvider.php This gives an error compiles to: this works... |
|
@it-can You have a typo in the directive. Blade::directive('auth', function ($guard = null) {
return "<?php if(auth()->guard({$guard})->check()): ?>";
});
Blade::directive('endauth', function () {
return "<?php endif; ?>";
}); |
|
@m1guelpf yes that works... but when I check this PR, the code is missing the parenthesis? |
| */ | ||
| protected function compileGuest($guard = null) | ||
| { | ||
| return "<?php if(auth()->guard{$guard}->guest()): ?>"; |
There was a problem hiding this comment.
Seems taylor changed it...
There was a problem hiding this comment.
No guys!
This is not the guard which is passed, but the complete $expression, with the ().
Nothing to change here!
There was a problem hiding this comment.
@mathieutu is rigth. There's nothing to change here.
| { | ||
| return '<?php endif; ?>'; | ||
| } | ||
|
|
There was a problem hiding this comment.
Remove the extra whitespace here, and your PR is perfect!
|
@m1guelpf @LKDevelopment Any ideas to work in @LKDevelopment's proposal? @auth
// Is authenticated
@guest
// Is guest
@endauth |
|
@Gabriel-Caruso I don't think so. Now it'd be a breaking change... |
As addition to #20087 it would be nice if there is the opposite of @auth, so i implemented it.