当前位置:网站首页>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>
边栏推荐
- Fatal error in golang: concurrent map writes
- 智能网关助力提高工业数据采集和利用
- Machine learning -- neural network (IV): BP neural network
- Intelligent gateway helps improve industrial data acquisition and utilization
- Exercise 9-4 finding books (20 points)
- PHP student achievement management system, the database uses mysql, including source code and database SQL files, with the login management function of students and teachers
- Hands on deep learning (45) -- bundle search
- Go context 基本介绍
- MATLAB小技巧(25)竞争神经网络与SOM神经网络
- Golang Modules
猜你喜欢
直方图均衡化
2022-2028 global gasket plate heat exchanger industry research and trend analysis report
The child container margin top acts on the parent container
Hands on deep learning (45) -- bundle search
How does idea withdraw code from remote push
PHP book borrowing management system, with complete functions, supports user foreground management and background management, and supports the latest version of PHP 7 x. Database mysql
Hands on deep learning (41) -- Deep recurrent neural network (deep RNN)
Hands on deep learning (39) -- gating cycle unit Gru
Machine learning -- neural network (IV): BP neural network
Summary of small program performance optimization practice
随机推荐
Write a mobile date selector component by yourself
Golang type comparison
Hands on deep learning (41) -- Deep recurrent neural network (deep RNN)
Exercise 9-1 time conversion (15 points)
Hands on deep learning (43) -- machine translation and its data construction
Histogram equalization
The child container margin top acts on the parent container
Flutter 小技巧之 ListView 和 PageView 的各種花式嵌套
Global and Chinese market of sampler 2022-2028: Research Report on technology, participants, trends, market size and share
2022-2028 global intelligent interactive tablet industry research and trend analysis report
PHP student achievement management system, the database uses mysql, including source code and database SQL files, with the login management function of students and teachers
System. Currenttimemillis() and system Nanotime (), which is faster? Don't use it wrong!
Svg image quoted from CodeChina
Pueue data migration from '0.4.0' to '0.5.0' versions
Fatal error in golang: concurrent map writes
【leetcode】29. Divide two numbers
C language pointer interview question - the second bullet
Hands on deep learning (33) -- style transfer
Leetcode (Sword finger offer) - 35 Replication of complex linked list
Kotlin set operation summary