I want to get all user’s favourite products. The query should be like this: How can I query with eloquent? 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()) :
Tag: laravel-query-builder
Laravel many to many relastionship count
I have two tables. User and days, with many to many relationship. user_days : user_id, day_id I want to get the count number of users in day_id = 1 {for a particular day} or something like this. Any way to get count from pivot table? This function didnot work. the table structure ? How do I find the user count
Laravel query Builder Select from subquery
I’m trying to convert a sql query to a Laravel Query builder, but i find hard understand which is the best way for FORM SUBQUERY in Laravel, because if i’m not wrong, is not something that you can normally do whit query builder, but you should implement in raw. is this right? and how should translate this? I could translate
How do I get the query builder to output its raw SQL query as a string?
Given the following code: I want to get the raw SQL query string that the database query builder above will generate. In this example, it would be SELECT * FROM users. How do I do this? Answer To output to the screen the last queries ran you can use this: I believe the most recent queries will be at the