Home:ALL Converter>Accessing a nested object in Laravel Blade

Accessing a nested object in Laravel Blade

Ask Time:2017-04-06T08:44:58         Author:Gavin Kemp

Json Formatter

What would the Blade syntax be for retrieving the following from a query response? The data is eager loaded. Each image is linked to a separate table. How do you access an object within an object in Blade? Pretty new to Laravel. Thanks!

enter image description here

Author:Gavin Kemp,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/43243846/accessing-a-nested-object-in-laravel-blade
brunohdaniel :

Once you pas them as data in your controller, inside your blade templates you should echo them as a objects:\n\n{{ $images[0]->id }}\n{{ $images[0]->host_image->path }}\n",
2017-04-06T01:00:07
meda :

Controller\n\nIn your action you need to pass the data to the blade view:\n\nreturn view('someview', compact('images'));//name of variable $images\n\n\nView\n\nJust use the variable:\n\n@foreach($image as $image)\n {{-- Do Something --}}\n@endForEach\n",
2017-04-06T00:52:24
yy