lundi 25 décembre 2017

Laravel: How to display the value of other table in a loop?

So, i have this code which is printing the various topics/threads started by user.

It is looping over the 'Posts' table that contains data related to posts.

In 'User' column, it will display 'user_id'. But i want to access 'User' table and display the 'user_name' column matching that 'user_id'. How to do this??

    <table border="2">
        <tr>
            <th>Topic</th>
            <th>User</th>
            <th>Replies</th>
            <th>Views</th>
            <th>Last Update</th>
        </tr>
        @foreach($topics as $topic)
        <tr>
            <td><a href="topics/"></a></td>
            <td></td>
            <td>0</td>
            <td>0</td>
            <td></td>
        </tr>
        @endforeach
    </table>



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2C4z76z
via IFTTT

Aucun commentaire:

Enregistrer un commentaire