code: public static function getQueryPreview(QueryBuilder $query = null)
  	{
  		if (empty($query)) {
  			return "";
  		}
  
  		$sql        = str_replace('?', "'%s'", $query->toSql());
  		$bindings   = $query->getBindings();
  
  		return vsprintf($sql, $bindings);
  	}
docs: Get a preview of what query will be run from a query builder.
  
  This DOES NOT run the query so it can be used for debugging potentially memory-intensive queries.
  
  @param QueryBuilder $query
  @return string