08-06-2023, 05:07 PM
It's also possible to typecast an object to an array. That worked for me here.
`(array) $object;`
will convert
stdClass Object
(
[id] => 4
)
to
Array(
[id] => 4
)
Had the same problem when trying to pass data from query builder to a view. Since data comes as object. So you can do:
$view = view('template', (array) $object);
And in your view you use variables like
{{ $id }}
`(array) $object;`
will convert
stdClass Object
(
[id] => 4
)
to
Array(
[id] => 4
)
Had the same problem when trying to pass data from query builder to a view. Since data comes as object. So you can do:
$view = view('template', (array) $object);
And in your view you use variables like
{{ $id }}