-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add blade directive @guest #20114
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this also be changed in #20087 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems taylor changed it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mathieutu is rigth. There's nothing to change here.
@@ -119,4 +119,25 @@ protected function compileEndAuth() | |||
{ | |||
return '<?php endif; ?>'; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.