1DB::enableQueryLog();
2$users = User::select("*")->get();
3$quries = DB::getQueryLog();
4dd($quries);
5DB::table('users')->toSql();
6dd($query);
1$query = str_replace(array('?'), array('\'%s\''), $builder->toSql());
2$query = vsprintf($query, $builder->getBindings());
3dump($query);
1DB::enableQueryLog(); // Enable query log
2
3// Your Eloquent query executed by using get()
4
5dd(DB::getQueryLog()); // Show results of log
6
1/**
2 * Combines SQL and its bindings
3 *
4 * @param \Eloquent $query
5 * @return string
6 */
7public static function getEloquentSqlWithBindings($query)
8{
9 return vsprintf(str_replace('?', '%s', $query->toSql()), collect($query->getBindings())->map(function ($binding) {
10 $binding = addslashes($binding);
11 return is_numeric($binding) ? $binding : "'{$binding}'";
12 })->toArray());
13}