Q:

Accessing database value with twig

Currently in in my php I have this:
$vals['followers'][] =  R::find('follow', 'following_id=?', array($_GET['id']));

I get a return of all followers in the "follow" table with a following_id of the id in the URL. The "follow" table consists of the following columns:
-id
-user_id
-following_id
I want to pull the 'firstname' of the user with an 'id' the same as the value of 'user_id'('user' table is joint with 'follow' table via user_id). For example if I write this:
 {%for follow in followers %}{{follow.user_id}}{%endfor%}

I want to add something to show the 'firstname' of the user such as:
{{follow.user_id}}->firstname

I know the above code is not valid but I hope it shows what I am trying to do. 
Please let me know if this doesn't make sense and I will try explain again.
Thank you so much in advanced!

A:

To take your words, this does not make sense in an MVC architecture (if you're using Twig, I assume you wish to design your application this way).
You should prepare what you want to display before rendering your view. So consider that $vals['followers'][] = R::find('follow', 'following_id=?', array($_GET['id'])); is a first step, and then you iterate $vals['followers'] (still in your controller) to complete the information you need to display.
Always remember that your view should display things, not recovering or calculating stuffs.

