如何在{{}}上设置{{}},我已经测试过,但始终是错误
这是我的代码:
PHP
$roles = DB::table('users')->where('id','=',Auth::user()->id)->pluck('role');
$role = $roles[0];
$removekoma = str_replace(",","",$role);
$arr1 = str_split($removekoma);
$one = array('0','1', '2', '3','4','5');
$two = array('Admin', 'Compiler', 'Evaluator NKK/NKD', 'Evaluator NKU', 'Facilitator', 'Bisiness User');
$three = array('/admin','/compiler', '/evaluatornkd', '/evaluatornku','/facilitator','/kpi');
刀片
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="fa fa-chevron-down"></span></a>
<ul class="dropdown-menu" role="menu">
@foreach($arr1 as $drop)
<li><a href="{{ url('({{$url= str_replace($one, $three, $drop)}}) ') }}">{{$name= str_replace($one, $two, $drop)}}</a>
@endforeach
</ul>
</li>
</ul>
答案 0 :(得分:1)
您可以像这样{{ url($url) }}
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="fa fa-chevron-down"></span></a>
<ul class="dropdown-menu" role="menu">
@foreach($arr1 as $drop)
@php $url= str_replace($one, $three, $drop); @endphp
<li><a href="{{ url($url) }}">{{str_replace($one, $two, $drop)}}</a>
@endforeach
</ul>
</li>
</ul>