[Vuejs]-Double link laravel tables

2👍

If you have relations in reviews for user, you can do this.

return $product->load('categories' , 'images', 'reviews', 'reviews.user');

Some helpful link.

Good luck!

👤mare96

1👍

public function show(Product $product)
{
    return $product->load('categories', 'images', 'reviews.user');
}

Or some advance level if you want to perform where query or access query builder

public function show(Product $product)
{
    return $product->load([
        'categories',
        'images',
        'reviews' => function ($query) {
            $query->where('field', 'value')->with('user');
        },
    ]);
}

Leave a comment