我如何设置如果管理员已登录,则只有他们可以看到他是索引上的管理员
how can i set If admin is logged in then only they can see he is admin on index
我有管理中间件,它只在路由上工作
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class admin
{
/**
* Handle an incoming request.
* this is only for admin
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!Auth::guest() && Auth::user()->admin) {
return $next($request);
}
return redirect('/');
}
}
如何让我看起来像
@if (Auth::user())
比用户看到的名字和管理员登录时比管理员会看到你好管理员
我为管理员输入的内容
提前谢谢你
假设您在用户 table 中有一个列角色:
@if(Auth::user()->role == 'admin')
<span>Hello{{Auth::user()->name}}</span>
or
<span>Hello admin</span>
@endif
如果您没有列角色,请将条件放在定义用户为管理员的 if 语句中
我有管理中间件,它只在路由上工作
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class admin
{
/**
* Handle an incoming request.
* this is only for admin
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!Auth::guest() && Auth::user()->admin) {
return $next($request);
}
return redirect('/');
}
}
如何让我看起来像
@if (Auth::user())
比用户看到的名字和管理员登录时比管理员会看到你好管理员
我为管理员输入的内容
提前谢谢你
假设您在用户 table 中有一个列角色:
@if(Auth::user()->role == 'admin')
<span>Hello{{Auth::user()->name}}</span>
or
<span>Hello admin</span>
@endif
如果您没有列角色,请将条件放在定义用户为管理员的 if 语句中