当前位置:网站首页>Laravel文档阅读笔记-How to use @auth and @guest directives in Laravel
Laravel文档阅读笔记-How to use @auth and @guest directives in Laravel
2022-07-04 09:35:00 【IT1995】
Laravel文档阅读笔记-How to use @auth and @guest directives in Laravel
这个是我在阅读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
在个人项目中,我是这样用的
<nav class="navbar navbar-dark bg-dark" style="z-index:999">
<div class="container-fluid">
<a class="navbar-brand" href="/">it1995.cn</a>
<ul class="navbar-nav justify-content-end">
@guest
<li class="nav-item">
<a class="nav-link text-white" href="{
{route('login')}}">登录</a>
</li>
@else
<li class="nav-item">
<div class="row">
<div class="col">
<a class="nav-link text-white" href="{
{route('dashboard')}}">管理</a>
</div>
<div class="col">
<a class="nav-link text-white" href="{
{route('signOut')}}">退出</a>
</div>
</div>
</li>
@endguest
</ul>
</div>
</nav>
边栏推荐
- QTreeView+自定义Model实现示例
- C语言指针面试题——第二弹
- MySQL foundation 02 - installing MySQL in non docker version
- Explanation of for loop in golang
- PHP is used to add, modify and delete movie information, which is divided into foreground management and background management. Foreground users can browse information and post messages, and backgroun
- How does idea withdraw code from remote push
- JDBC and MySQL database
- 2022-2028 global gasket plate heat exchanger industry research and trend analysis report
- Hands on deep learning (35) -- text preprocessing (NLP)
- Leetcode (Sword finger offer) - 35 Replication of complex linked list
猜你喜欢
Custom type: structure, enumeration, union
Svg image quoted from CodeChina
IIS configure FTP website
Daughter love: frequency spectrum analysis of a piece of music
Summary of small program performance optimization practice
2022-2028 global elastic strain sensor industry research and trend analysis report
Hands on deep learning (44) -- seq2seq principle and Implementation
直方图均衡化
Hands on deep learning (36) -- language model and data set
2022-2028 global small batch batch batch furnace industry research and trend analysis report
随机推荐
lolcat
Pueue data migration from '0.4.0' to '0.5.0' versions
el-table单选并隐藏全选框
Kotlin:集合使用
Global and Chinese markets of water heaters in Saudi Arabia 2022-2028: Research Report on technology, participants, trends, market size and share
Mmclassification annotation file generation
2022-2028 global gasket metal plate heat exchanger industry research and trend analysis report
Exercise 7-8 converting strings to decimal integers (15 points)
2022-2028 global gasket plate heat exchanger industry research and trend analysis report
Upgrading Xcode 12 caused Carthage to build cartfile containing only rxswift to fail
2022-2028 global edible probiotic raw material industry research and trend analysis report
Hands on deep learning (45) -- bundle search
Hands on deep learning (41) -- Deep recurrent neural network (deep RNN)
Hands on deep learning (33) -- style transfer
Svg image quoted from CodeChina
Log cannot be recorded after log4net is deployed to the server
Machine learning -- neural network (IV): BP neural network
Dynamic memory management
2022-2028 global tensile strain sensor industry research and trend analysis report
Write a jison parser (7/10) from scratch: the iterative development process of the parser generator 'parser generator'