vendredi 16 octobre 2015

Laravel Blade access object property using variable

In a blade template y controller passes a object which has few values in properties as bellow

value_L1 = "Hello"
value_L2 = "Stack"
value_L3 = "OverFlow"

I want to use a for loop to display these values but the statement in loop returns null, how can I do such a thing in blade?

@for ($count = 1; $count < 3; $count++)
    {{ $object->{'value_L.$count'} }}
@endfor

I am able to access these properties as following

{{ $object->value_L1 }}
{{ $object->value_L2 }}

Thanks,

K



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire