Support the ongoing development of Laravel.io →
Database Views
Last updated 2 years ago.
0

Presuming you have the total amount of posts in a posts array you can use the length twig filter

Displaying {{ posts|length }} posts
0

What do you even mean by a view?
Is it how many times a request is made to a post?

If so how are you tracking views of a post? Do you have a views field on the post that is incremented each time a post is "viewed"? Do you have a post views table that is being inserted into whenever a post is "viewed"? Are you using an external tracking service like Piwik or Google Analytics?

Or is that what you are asking "What is a way to track views of a post?"

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Agroorama agroorama Joined 2 Feb 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.

© 2024 Laravel.io - All rights reserved.