Laravel Blade fails in forelse, works in foreach
<p>I am upgrading Laravel from 5.2 to 5.3 and one of my Blade views is no longer working. I am passing an array to an included view to loop through it. I am using the <code>forelse</code> directive but it keeps giving me an Undefined offset: 1 error.</p>

<p>Here is the controller snippet with the view call:</p>

<pre><code>$transactions = $committees-&gt;transactions()
    -&gt;where('FiledDate', '&lt;=', $to)  // Upper date
    -&gt;where('FiledDate', '&gt;=', $from)  // Lower date
    -&gt;get();

return view('committees.show',
    [ 
        'data' =&gt; $data,
        'transactions' =&gt; $transactions,
    ]);
</code></pre>

<p>Here is the Blade file.</p>

<pre class="lang-xml prettyprint-override"><code>&lt;table class="table table-striped"&gt;
&lt;thead&gt;
    &lt;tr&gt;&lt;th class="text-center" colspan="5"&gt;Transactions&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;
        &lt;th class="text-center"&gt;TranId&lt;/th&gt;
        &lt;th class="text-center"&gt;Tran Date&lt;/th&gt;
        &lt;th class="text-center"&gt;SubType&lt;/th&gt;
        &lt;th class="text-center"&gt;Filed Date&lt;/th&gt;
        &lt;th class="text-center"&gt;Amount&lt;/th&gt;
    &lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
@forelse ($transactions AS $transaction)
    &lt;tr&gt;
        &lt;td class="text-center"&gt;{{ $transaction-&gt;TranId }}&lt;/td&gt;
        &lt;td class="text-center"&gt;{{ $transaction-&gt;TranDate }}&lt;/td&gt;
        &lt;td class="text-center"&gt;{{ $transaction-&gt;SubType }}&lt;/td&gt;
        &lt;td class="text-center"&gt;{{ $transaction-&gt;FiledDate }}&lt;/td&gt;
        &lt;td class="text-center"&gt;{{ number_format($transaction-&gt;Amount, 2, '.', ',') }}&lt;/td&gt;
    &lt;/tr&gt;
@empty
    &lt;tr&gt;&lt;td colspan="5"&gt;No Transactions&lt;/td&gt;&lt;/tr&gt;
@endforelse
&lt;/tbody&gt;              
</code></pre>

<p></p>

<p>I have created a dummy transaction array but I still got the same error.</p>

<p>Also, when I use the <code>foreach</code> directive it works fine but then I have to have an additional test of checking for no records.</p>