Ad

Double Link Laravel Tables

- 1 answer

I'm creating an e-commerce in laravel and vue js. I am in the following situation

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

From this through an axios I can trace all my tables connected to the products. Now, however, I would need to trace from reviews also the users table with which they have a connection. How can I do this on my controller? Such a thing

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

Answer

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!

Ad
source: stackoverflow.com
Ad