S
S
syndarva2020-09-30 13:56:15
Laravel
syndarva, 2020-09-30 13:56:15

How to get a list of products, given their availability in the desired ones?

Good afternoon.
The situation is this: there are three tables

users - id, ...;
products - id, ...;
user_wishlist_products - id, user_id, product_id, ...;

Is it possible to use a join or something similar to display products, taking into account the presence in the wishlist, as elegantly and correctly as possible? Ideally, I would like this information to be displayed in a separate boolean field in_wishlist.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2020-09-30
@syndarva

Well, if completely with the help of eloquent, then there is "withCount" , incl. with selection, which can then be converted to boolean

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question