DEV Community

Debajyoti Das
Debajyoti Das

Posted on

Laravel useful DB/Eloquent functions:

Getting raw sql's from eloquent query.

DB::enableQueryLog();
$spam_events = SpamEvent::where('user_id', $user_id)->pluck('event_id');

$users = User::all();
dd(DB::getQueryLog());
Enter fullscreen mode Exit fullscreen mode

Raw SQL's will be shown

More methods will be updated soon.

Top comments (0)