S
S
semki0962019-04-13 12:49:51
Twig
semki096, 2019-04-13 12:49:51

How to correctly display data from a collection in twig, using an example?

I am working with Eloquent collections and need to pass them to Twig. I have such a collection
$product = Product::find($id);
Since this is one product, in theory it can be displayed in a twig either in a cycle, or like this {{ product.0.name }}.
Are there any other options in Twig, perhaps more correct?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Wells, 2019-04-13
@Alex_Wells

This is not a collection. This is a model object. No, you can't cycle.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question