Support the ongoing development of Laravel.io →
Eloquent Views Blade

the solution must be simple but i cant see it

Iam passing an array to the view, whit all the fields that i want to display in a table, and whats the name of the attribute. When this attributes are from the class i have no problem. When correspond to a related object echos nothing.

Array example:

$fields = [
        [
          'field' => 'id_user',
          'det' => 'Id user',
          'class' => 'sorting',
          'index' => '1',
        ],
        [
          'field' => 'rol->Name',
          'det' => 'Rol',
          'class' => '',
          'index' => '5',
        ],
@foreach($fields as $f)
      <td>{!! $user->$f['field'] !!}</td>
@endforeach

if i hardcode $user->rol->Name works perfectly, so the objects and the relationship i assume is well formed.

THKS!!!!

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

kkpatula kkpatula Joined 3 Jun 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.