-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,4 +119,25 @@ protected function compileEndAuth() | |
{ | ||
return '<?php endif; ?>'; | ||
} | ||
|
||
/** | ||
* Compile the if-guest statements into valid PHP. | ||
* | ||
* @param string|null $guard | ||
* @return string | ||
*/ | ||
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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. No guys! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mathieutu is rigth. There's nothing to change here. |
||
} | ||
|
||
/** | ||
* Compile the end-guest statements into valid PHP. | ||
* | ||
* @return string | ||
*/ | ||
protected function compileEndGuest() | ||
{ | ||
return '<?php endif; ?>'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Blade; | ||
|
||
use Mockery as m; | ||
use PHPUnit\Framework\TestCase; | ||
use Illuminate\View\Compilers\BladeCompiler; | ||
|
||
class BladeIfGuestStatementsTest extends TestCase | ||
{ | ||
public function tearDown() | ||
{ | ||
m::close(); | ||
} | ||
|
||
public function testIfStatementsAreCompiled() | ||
{ | ||
$compiler = new BladeCompiler($this->getFiles(), __DIR__); | ||
$string = '@guest("api") | ||
breeze | ||
@endguest'; | ||
$expected = '<?php if(auth()->guard("api")->guest()): ?> | ||
breeze | ||
<?php endif; ?>'; | ||
$this->assertEquals($expected, $compiler->compileString($string)); | ||
} | ||
|
||
protected function getFiles() | ||
{ | ||
return m::mock('Illuminate\Filesystem\Filesystem'); | ||
} | ||
} |
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!