if else条件在刀片文件中(laravel 5.3)

时间:2016-10-19 05:11:18

标签: php laravel

我想检查我的刀片文件中是否有其他情况。  我想检查$user->status =='waiting'作为下面给出的代码。输出正确地返回我所期望的。但是我的输出我抓到上面打印的花括号{}我删除大括号。我的if条件有什么问题

@if($user->status =='waiting')
         {
           <td><a href="#" class="viewPopLink btn btn-default1" role="button" data-id="{{ $user->travel_id }}" data-toggle="modal" data-target="#myModal">Approve/Reject<a></td>
         }
         @else{
           <td>{{ $user->status }}</td>
         }
         @endif

2 个答案:

答案 0 :(得分:28)

没有花括号可以直接写

@if($user->status =='waiting')         
      <td><a href="#" class="viewPopLink btn btn-default1" role="button" data-id="{{ $user->travel_id }}" data-toggle="modal" data-target="#myModal">Approve/Reject<a></td>         
@else
      <td>{{ $user->status }}</td>        
@endif

答案 1 :(得分:1)

我认为你要放一个太多的花括号。试试这个

 @if($user->status=='waiting')
            <td><a href="#" class="viewPopLink btn btn-default1" role="button" data-id="{!! $user->travel_id !!}" data-toggle="modal" data-target="#myModal">Approve/Reject</a> </td>
            @else
            <td>{!! $user->status !!}</td>
        @endif