如何在laravel中制作水平-垂直表? (交叉表)[编辑]

时间:2019-07-20 10:41:26

标签: php arrays laravel foreach laravel-5.8

我已经尝试了很多步骤来制作这张桌子(第二张桌子):

second table

具有此数组

{
  "Habie": {
    "2019-07-17": [
      {
        "durasi": "0 Jam",
        "status_durasi": "Kurang"
      }
    ],
    "2019-07-07": [
      {
        "durasi": "0 Jam",
        "status_durasi": "Kurang"
      }
    ]
  },
  "Budiman": {
    "2019-07-13": [
      {
        "durasi": "0 Jam",
        "status_durasi": "Kurang"
      }
    ]
  }
}

,并且表头的数组日期间隔为:

[
  "2019-07-20",
  "2019-07-19",
  "2019-07-18",
  "2019-07-17",
  "2019-07-16",
  "2019-07-15",
  "2019-07-14",
  "2019-07-13",
  "2019-07-12",
  "2019-07-11",
  "2019-07-10",
  "2019-07-09",
  "2019-07-08",
  "2019-07-07"
]

然后,在刀片中,我像这样循环播放:

             <tr>
                <th>NAMA</th>
                @foreach ($tanggalInterval as $key => $item)
                    <th>{{$item}}</th>
                @endforeach
            </tr>

            <tr>
                @foreach ($kehadiran as $kData=> $data)
                    <td>{{$kData}}</td>
                    @foreach ($data as $kTanggal => $tanggal)
                        @foreach ($tanggal as $kDrsSts => $item)
                            @foreach ($item as $kItem => $drs)
                            {{-- {{dd()}} --}}
                                {{-- <td>{{$item["durasi"]}}</td> --}}
                            @endforeach
                        @endforeach
                    @endforeach
                @endforeach
            </tr>

Nb:从总工时(durasi)中找到总计

但是,没有一步可以工作:(。

我希望有人可以帮助我:)

感谢:D


已编辑

来自此数据库表:

database Table

成为:

The table that i want

0 个答案:

没有答案