0
votes

I am getting some weird error while working with blade.

It works just like it should when getting the data inside a dd(), but when calling it without a dd(), an error is thrown telling me that it can't find a field in my object.

In my blade file, this works just fine:

{{ dd($p->components->image->lg_img) }}

This doesn't:

<img src="{{ $p->components->image->lg_img }}" />

The error:

Undefined property: stdClass::$image (View: /home/vagrant/code/xxxxxx/resources/views/resources.blade.php)

what are $p and components?Juan Eizmendi
Is it in loop? If so then first loop element has it set and some other doesn't.NoOorZ24
You can also comment out that img tag and use @dump $p->components @enddump for debuggingNoOorZ24
I found the solution, when some of the objects in the loop didn't contain the attribute.Jean-Paul Abi-Ghosn