1// query builder
2$query = DB::table('table_name')->where('id', 1);
3// binding replaced
4$rawQuery = str_replace_array('?', $query->getBindings(), $query->toSql());
5// for laravel 5.8^
6$rawQuery = Str::replaceArray('?', $query->getBindings(), $query->toSql());
7
8dd($rawSql); // "select * from `table_name` where `id` = 1";