[Vuejs]-Displaying related table data in vuejs

0👍

Judging by what you posted you could get the article translation attributes like this:

<div v-for="article in articles" :key="article.articles">
    <div v-for="translation in article.translations">
        <h4>{{ translation.title }}</h4>
        {{ translation.subtitle }}
        {{ translation.content }}
    </div>
</div>

Basically add another for loop, since your translations are in an array. And then simply display the attributes.

0👍

just use the Laravel query builder the inner join will help to your problem this is a quick example then you will receive the collection of properties or your object.

explanation: users table get a User object, people table is related to the user with user_id column. just need to join tables related and get this resultenter image description here

$users = DB::table('people')
        ->join('users', 'users.id', '=' ,'people.user_id')
        ->select('users.*',
            'first_name',
            'last_name',
            'street_address',
            'city',
            'state',
            'contact_phone'
        )->get();

    return response()->json(['data' => $users], 200);

Leave a comment