Skip to content
Advertisement

Select from select using Laravel eloquent

I want to get all user’s favourite products. The query should be like this:

How can I query with eloquent?

Advertisement

Answer

You’re trying to achieve something like this:

In the oficial documentation you can find the explanation of Advanced where clauses

The final result will be (you can see this dumping the query using toSql() method instead of get()) :

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement