这个是我在阅读Laravel8中的文档时遇到的。在此阅读下@auth和@guest的用法。
下面将说明@auth和@guest在Laravel中的使用。
这两个关键字其实是代替@if、@endif的。
如下使用@if、@endif
@if(auth()->user())
// The user is authenticated.
@endif
当用户有权限,就在blade中显示。
使用@auth和@guest可以简化成这样的:
@auth
// The user is authenticated.
@endauth
和
@guest
// The user is not authenticated.
@endguest
在个人项目中,我是这么用的:
```
```