当前位置:网站首页>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>
边栏推荐
- C # use smtpclient The sendasync method fails to send mail, and always returns canceled
- Svg image quoted from CodeChina
- How can people not love the amazing design of XXL job
- Mmclassification annotation file generation
- Ultimate bug finding method - two points
- Latex download installation record
- 智能网关助力提高工业数据采集和利用
- Hands on deep learning (43) -- machine translation and its data construction
- Global and Chinese markets of hemoglobin analyzers in care points 2022-2028: Research Report on technology, participants, trends, market size and share
- 2022-2028 global gasket metal plate heat exchanger industry research and trend analysis report
猜你喜欢

2022-2028 global elastic strain sensor industry research and trend analysis report

The child container margin top acts on the parent container

Intelligent gateway helps improve industrial data acquisition and utilization

2022-2028 global strain gauge pressure sensor industry research and trend analysis report

Hands on deep learning (38) -- realize RNN from scratch

Latex download installation record

2022-2028 global industrial gasket plate heat exchanger industry research and trend analysis report

Four common methods of copying object attributes (summarize the highest efficiency)

2022-2028 global gasket plate heat exchanger industry research and trend analysis report

C # use gdi+ to add text to the picture and make the text adaptive to the rectangular area
随机推荐
Machine learning -- neural network (IV): BP neural network
Qtreeview+ custom model implementation example
JDBC and MySQL database
libmysqlclient.so.20: cannot open shared object file: No such file or directory
Exercise 9-4 finding books (20 points)
ASP. Net to access directory files outside the project website
C # use ffmpeg for audio transcoding
2022-2028 global visual quality analyzer industry research and trend analysis report
Global and Chinese market of air fryer 2022-2028: Research Report on technology, participants, trends, market size and share
品牌连锁店5G/4G无线组网方案
On Multus CNI
Golang Modules
Are there any principal guaranteed financial products in 2022?
【leetcode】29. Divide two numbers
Upgrading Xcode 12 caused Carthage to build cartfile containing only rxswift to fail
2022-2028 global seeder industry research and trend analysis report
Web端自动化测试失败原因汇总
Kubernetes CNI 插件之Fabric
Mmclassification annotation file generation
2022-2028 global special starch industry research and trend analysis report