title: Foreach loop with json data laravel
body: <p>I want to make a table in html with json data using laravel excel, the data looks like this</p>
  <pre><code>4 =&gt; {
      +&quot;id&quot;: 5
      +&quot;date&quot;: &quot;2020-1-3&quot;
      +&quot;grade&quot;: &quot;7&quot;
      +&quot;nama&quot;: &quot;[&quot;bryan&quot;,&quot;anderson&quot;]&quot;
      +&quot;status&quot;: &quot;[&quot;active&quot;,&quot;active&quot;]&quot;
  }
  </code></pre>
  <p>the excel file output i was hoping for is
  <a href="https://i.stack.imgur.com/FR8Uw.png" rel="nofollow noreferrer">this</a>. <strong>Status</strong> fill the column based on dates and if there is no data in particular date the column will filled with &quot;-&quot;. I tried a foreach loop I found here, but did not have any luck.</p>
  <p>I call the data with <code>$reports</code>, for example <code>$reports-&gt;status</code> will return <code>[&quot;active&quot;,&quot;active&quot;]</code> and so on.</p>
  <p>This is the code i am working on</p>
  <pre><code>&lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;No.&lt;/th&gt;
              &lt;th&gt;Name&lt;/th&gt;
              @for ($i = 1; $i &lt; 32; $i++)
                  &lt;th&gt;{{ $i }}&lt;/th&gt;
              @endfor
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          @foreach ($reports as $rp)
              &lt;tr&gt;
                  &lt;td&gt;{{ $loop-&gt;iteration }}&lt;/td&gt;
                      &lt;!--INSERT DATA HERE--&gt;
                  &lt;td&gt;&lt;/td&gt;
              &lt;/tr&gt;
          @endforeach
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  <p>dd($reports) return =</p>
  <pre><code>array:2 [▼
  0 =&gt; {#455 ▼
      +&quot;id&quot;: 17
      +&quot;date&quot;: &quot;2021-01-03&quot;
      +&quot;grade&quot;: &quot;7&quot;
      +&quot;nama&quot;: &quot;[&quot;bryan&quot;,&quot;anderson&quot;]&quot;
      +&quot;status&quot;: &quot;[&quot;active&quot;,&quot;active&quot;]&quot;
      +&quot;created_at&quot;: &quot;2021-01-23 05:33:27&quot;
      +&quot;updated_at&quot;: &quot;2021-01-23 05:33:27&quot;
    }
    1 =&gt; {#1414 ▶}
  ]
  </code></pre>