php - Blade 引擎元素渲染排序

标签 php html css laravel laravel-blade

我有这段代码:

<div class="table-responsive">
  <table class="table table-condensed table-hover">
    <tr>
    <th>#</th>
    <th>Name</th>
    <th>username</th>
    <th>Email</th>
    <th>Rank</th>
    <th>Join</th>
  </tr>
  @if($count)
      @foreach($users as  $i => $user)
      <tr>
      <td>{{ $i+1 }}</td>
      <td>{{ $user->first_name }} {{ $user->last_name }}</td>
        <td>{{ $user->username }}</td>
        <td>{{ $user->email }}</td>
        <td>
            @if($user->rank == 0)
              Admin
            @else
              User
            @endif
        </td>
        <td>{{ $user->created_at }}</td>
        {{ Form::hidden('id', $user->id,['class'=>'id']) }}
        {{ Form::hidden('username', $user->username,['class'=>'username']) }}
        <td><button id="submit" type="button" class="btn btn-danger" data-toggle="modal" data-target="#deleteModal">
          Delete
        </button></td>
      </tr>
      @endforeach
  @else
  <div class="alert alert-success" style="text-align:center">
      There is no users in the Site
  </div>
  @endif

它使用了 Blade Template 引擎,但如果计数为假,则警报 div 出现在表标题之前

如何解决这个问题?

最佳答案

我可能在这里遗漏了一些东西,上面的代码似乎不完整(表格没有关闭)。但是,为什么不将您的警报移到另一个之外,如果这样您就可以将它放在您需要的地方:

@if(!$count)
  <div class="alert alert-success" style="text-align:center">
  There is no users in the Site
  </div>
@endif

关于php - Blade 引擎元素渲染排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46064571/

相关文章:

javascript - 如何更改 bootstrap4 中滚动时垂直导航栏的颜色?

javascript - 调整元素与容器面板相同的高度

php - Laravel Forge 上的 Laravel Nova 错误 403 页面

php - 如何使用 Slim Framework 查询和回显列中的所有数据

php - 您能否禁止单个无法解析/编译的 php 文件在 Eclipse 中显示为错误?

jquery - 设置表格组件以使用整个视口(viewport)高度显示

html - 是否可以更改 SSRS 中 Web 服务界面的外观?

php - 重定向到子域的规则

javascript - 如何将javascript代码注入(inject)到iframe中?

javascript - 如何使用 HTML、CSS 和 JQuery 使菜单从移动设备的右侧滑动?