Skip to content

Commit

Permalink
Add L8 Support and fix for getting SQL string
Browse files Browse the repository at this point in the history
  • Loading branch information
MCMatters committed Sep 17, 2020
1 parent 498bbdf commit e1e9092
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
],
"require": {
"php": ">=7.0",
"illuminate/support": "5.* || 6.* || 7.*",
"illuminate/database": "5.* || 6.* || 7.*",
"illuminate/console": "5.* || 6.* || 7.*",
"illuminate/support": "5.* || 6.* || 7.* || 8.*",
"illuminate/database": "5.* || 6.* || 7.* || 8.*",
"illuminate/console": "5.* || 6.* || 7.* || 8.*",
"symfony/debug": "3.* || 4.* || 5.*",
"symfony/http-foundation": "3.* || 4.* || 5.*",
"symfony/process": "3.* || 4.* || 5.*"
Expand Down
18 changes: 10 additions & 8 deletions src/Helpers/DbHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,20 @@ class DbHelper
public static function compileSqlQuery($sql, array $bindings = null): string
{
if (!is_string($sql)) {
if (!method_exists($sql, 'toSql')) {
try {
$sqlQuery = $sql->toSql();
} catch (Throwable $e) {
throw new InvalidArgumentException('"$sql" must be string or Query object.');
}

if (null === $bindings) {
$bindings = self::getBindings($sql);
}

$sql = $sql->toSql();
} else {
$sqlQuery = $sql;
}

return self::replaceBindings($sql, $bindings ?: []);
return self::replaceBindings($sqlQuery, $bindings ?: []);
}

/**
Expand Down Expand Up @@ -150,10 +152,10 @@ public static function getBaseQuery($query)
*/
public static function getBindings($query): array
{
$bindings = [];

if (method_exists($query, 'getBindings')) {
$bindings = $query->getBindings();
try {
return $query->getBindings();
} catch (Throwable $e) {
$bindings = [];
}

$baseQuery = self::getBaseQuery($query);
Expand Down

0 comments on commit e1e9092

Please sign in to comment.