I have this query here:
SELECT p.descr, p.dt_hr, f.id_friend
FROM users u
JOIN friends f ON u.id = f.id_user
JOIN posts p ON p.id_user = f.id_friend
WHERE u.id = 1
It returns me this:
I'mwantingtospinintheforeachandmountanarraysomethinglikethis:
[0]=>['descr'=>$ln['descr'],<br>'dt_hr'=>$ln['dt_hr'],<br>'name'=>$this->getNameByIdFriend($ln['id_friend'])//pegaronomedesseusuário]
Inthismethod"getNameByIdFriend", I would make a select in another table by taking the id I passed to return the name to my position name of my array.
I do this using Zend Framework 2, I wanted to know how I can do it with laravel.
Thank you!