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

hillcow's avatar

Database Query returns object - how do I get it's values to display?

Hi there,

I guess there is a simple solution to my problem, I'm just a beginner :D

On one of my controllers I have a fairly complex DB::table...... request that returns an object and not an array (and I think I cannot perform the request with Eloquent). Now I don't know how I get these values to actually display inside my blade page? Do I have to somehow convert it to an array to do that?

(query: https://stackoverflow.com/a/44929504/6399812)

Thank you very much!

0 likes
1 reply
Cronix's avatar

You can convert it to an array, or just use object syntax in your view, like {{ $object->name }} to output the name property of $object

which is the same as:

$object->toArray(); // in controller before sending to view

{{ $object['name'] }}

Please or to participate in this conversation.