I have some query that I need to pass to another query using query builder
$query = DB::table(\'table\')->whereIn(\'some_field\', [1,2,30])->toSql();
Mode
Building upon Douglas.Sesar's answer.
I found I also needed to put the bindings in single quotations to be able to easily paste it into my database IDE.
$sql = $query->toSql();
$bindings = $query->getBindings();
$sql_with_bindings = preg_replace_callback('/\?/', function ($match) use ($sql, &$bindings) {
return "'" . array_shift($bindings) . "'";
}, $sql);