laravel get query in normal sql without bindings

Solutions on MaxInterview for laravel get query in normal sql without bindings by the best coders in the world

showing results for - "laravel get query in normal sql without bindings"
Virgil
26 Oct 2016
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}