Reputation:
Is there a way to see what the raw version of my query looks like from my Eloquent query?
For example, if I have this Eloquent query:
$users = User::where('votes', '>', 100)->take(10)->get();
How could I have it output the raw version of the query, i.e.:
SELECT * FROM users WHERE votes > 100 LIMIT 10
Thanks.
Upvotes: 0
Views: 251
Reputation: 10538
You can get the raw query output using toSql()
:
$myRawQuery = User::where('votes', '>', 100)->take(10)->toSql();
Or you can use dd(DB::getQueryLog());
to output the latest queries you've run.
Upvotes: 1