Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

princelionelnzi's avatar

dd() displays the value of an object but unable to diplay it using Laravel double Curly brackets syntax

I am having this code in my view:

@foreach($offers as $offer)           
         
    <p>{{ $offer->provider->name }}</p>

@endforeach

And I am getting this error : Trying to get property of non-object

But when I use dd() as follow :

@foreach($offers as $offer)           
         
    <p>{{ dd($offer->provider->name) }}</p>

@endforeach

I can see the name of the provider. Any Idea ?

0 likes
2 replies
phpMick's avatar
phpMick
Best Answer
Level 15

Do all the offers have provide->name?

You could dd $offers and see.

Mick

1 like
JoaoSantos's avatar

Use dd($offer) and check if all the offers have a provider and if all the providers have a name. In case one does not have use if's to check before displaying it.

1 like

Please or to participate in this conversation.