从 Laravel 中的存储过程列动态显示 HTML Table 列

Show HTML Table with Columns Dynamically From Stored Procedure Columns in Laravel

我有一个带有一些参数的存储过程。我想显示带有列名的 HTML Table 应该是存储过程中的列名。我该怎么做?

示例: 我正在执行我的存储过程 CALL_LIST,2020-06-01,2020-06-03。这里 CALL_LIST 是存储过程名称,2020-06-01 和 2020-06-03 是参数。

存储过程的结果将是这样的

    +---------+-------------+-----------+-----------+
    | Emp_Code | 01-06-2020 | 02-06-2020| 03-06-2020|
    +----------+------------+-----------+-----------+
    |       1  | 10:00      |   09:00   |   10:00   |
    |       2  | 10:00      |   10:00   |   10:00   |
    |       3  | 10:00      |   10:00   |   10:00   |
    +----------+------------+-----------+-----------+

我的要求是根据传递给存储 procedure.like 的日期创建动态列,我在这里传递了 2020-06-01 和 2020-06-03,因此需要生成 3 个动态列并带有值。如果我通过 2020-06-01 和 2020-06-10,则必须生成 10 个动态列并显示值。

例子

<table>
<thead>
     <tr>
      <th>Emp Code</th>
      <?php $begin = new DateTime($datefrom);
        $end = new DateTime($dateto);
        $end = $end->modify('+1 day');
        $interval = new DateInterval('P1D');
        $daterange = new DatePeriod($begin, $interval, $end); 
       foreach ($daterange as $date_val) {
        <th scope="col">$date_val->format('d-m-Y')</th>
        } ?>
     </tr>
</thead>
<tbody><?php foreach ($data as $val) { ?>
   <tr>
      <td>{{$val->Emp_Code.}}</td>
   </tr><?php } ?>
</tbody>
</table>

如何显示存储过程中的列值?

我得到了结果

<table>
<thead>
     <tr>
      <th>Emp Code</th>
      <?php $begin = new DateTime($datefrom);
        $end = new DateTime($dateto);
        $end = $end->modify('+1 day');
        $interval = new DateInterval('P1D');
        $daterange = new DatePeriod($begin, $interval, $end); 
       foreach ($daterange as $date_val) {
        <th scope="col">$date_val->format('d-m-Y')</th>
        }
            $dates = array();
            foreach ($daterange as $key => $date) {
                $dates[$key] = $date->format('Y-m-d');
            }   ?>
     </tr>
</thead>
<tbody><?php foreach ($data as $val) { ?>
   <tr>
      <td>{{$val->Emp_Code}}</td>
      <?php foreach($dates as $val){
        <td>{{$row->{$val}}}</td>
           <?php } ?>
   </tr><?php } ?>
</tbody>
</table>