Open JarJak opened 5 years ago
The lazy collection is still the array of entities, you can iterate and use them as normal, just that they are loaded just in time.
{% for page in records.related('pages') %}
{{ dump(page) }}
{% endfor %}
This will give you an actual instance of Entity\Content
as expected
We can possibly look at changing this behaviour, the plan is to make the loading strategy configurable and I have a WIP branch for this but it's going to target a follow-up release since it was too big a feature to be finished in time for 3.6
@rossriley thanks, it works :) However, how can I get it from inverse side of relation?
If you call it from reverse side {{ dump(relatedrecord.related('maintype')) }} you get ArrayIterator<Bolt\Storage\Entity\Relations>
This issue has been automatically marked as stale because it has not had recent activity. Maybe this issue has been fixed in a recent release, or perhaps it is not affecting a lot of people? It will be closed if no further activity occurs, because we like to keep the issue queue concise and actual. If you think this issue is still relevant, please let us know. Especially if you’d like to help resolve the issue, either by helping us pinpointing the cause of a bug, or in implementing a fix or new feature.
dont!
Added 'keep' :-)
According to the docs: To get the actual related records, use the function related()
But it never happens.
Consider there is a relation maintype -> relatedtype.
If you call
{{ dump(mainrecord.related('relatedtype')) }}
you getBolt\Storage\Collection\LazyCollection<Bolt\Storage\EntityProxy>
If you call it from reverse side
{{ dump(relatedrecord.related('maintype')) }}
you getArrayIterator<Bolt\Storage\Entity\Relations>
What about record.relation then?
If you call
{{ dump(mainrecord.relation) }}
you getBolt\Storage\Collection\Relations<Bolt\Storage\Entity\Relations>
If you call
{{ dump(mainrecord.relation.relatedtype) }}
you get an error./cc @rossriley