New answers tagged templating
1
vote
Accepted
How to implement Laravel's collection `filter` method inside twig?
Use the filter filter.
{% set filtered = items|filter(item => item > 2) %}
https://craftcms.com/docs/3.x/dev/filters.html#filter
Top 50 recent answers are included
Related Tags
templating × 1654entries × 130
craft3 × 123
plugin-development × 94
matrix × 82
categories × 64
assets × 62
forloop × 47
field × 46
variable × 46
filter × 40
datetime × 39
plugin-craftcommerce × 37
array × 35
url × 34
conditional × 34
entry × 33
cache × 32
navigation × 30
users × 29
routes × 29
plugins × 27
sections × 26
image × 23
javascript × 23