mardi 19 février 2019

How to fetch data with one to one relationship using laravel+VueJS

How can i show the name of user using a foreign key? i have 2 tables: users and departements, one departement have only one cheif. and a user can be a cheif of only one departement. So i think it's a "one to one relationship". the departement table have the"user_id" as a foreign key from the table users. In the vue i have:

<tr v-for="departement in departements" :key="id" >
                <td></td>
                <td></td>
                <td></td>
                <td></td>

So i want to display the name of the user from users table who has the user_id. Thank you.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire