Hey,
this is about some sort of forum. I have 3 tables:
- forum
- user
- forumRead
These are linked properly via the models. (forumRead [two belongs to] and forum + user with [has many]). I do get the last 10 forums with:
$this->view->forum = Forum::find(array("status != 'in_creation' AND status != 'closed'", "order" => "id DESC", "limit" => "10"));
Now I would like to mark the unread ones. The forum table does include a updated_at
timestamp and the forumReadAt the list time the user visited that specific forum.
In volt I can go either from the forum or user perspective. In case of forum perspective:
{% if forum.updated_at > forum.forumRead.ticket_read_at %} unread {% endif %}
Of course this doesn't know as there is more than one user. How can implement the user using the volt syntax?
{% if forum.updated_at > forum.forumRead.[WHERE user_id = user.id].ticket_read_at %} unread {% endif %}
Or would you manage to do it? If possible I would like to avoid iterating through all users or tickets.