I run code like this in a template in the latest Sage beta theme
@foreach ($elements as $element)
I get this error: Call to a member function addLoop() on null
I looked into the compiled template and found the offending code:
Is anybody else experiencing the same issue, or is it just me?
That error means the variable
$elements is null. Possibly you have not created that variable in a controller yet?
Thanks for trying, but nope, i did create a var directly in the template. normal <?php foreach ?> works, @foreach does not. I appears that $__env is a null, why is beyond me.
If there isn’t a controller for your template, then the data variables will not be created. This includes the
OK, I added a function to app controller. tried accessing it as a variable in the template. same error occurs. besides i thought that creating arrays directly in the template and looping over them with @foreach was still legal.
Did you ever figure this out? I’m having a very similar issue.
I don’t understand why the variable (an array in my case) is accessible through a normal php foreach, but not a blade one…
This was quite a bit of time ago. From what I can recall, I either updated composer deps in the sage theme folder or just reinstalled it. Sorry not the best answer, let me know what works for you.