Skip to content

Commit

Permalink
Fix DateTime conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
MCMatters committed Nov 13, 2023
1 parent f02c910 commit f9fbb86
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Helpers/DbHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace McMatters\Helpers\Helpers;

use DateTime;
use Illuminate\Container\Container;
use Illuminate\Support\Arr;
use Stringable;
Expand Down Expand Up @@ -186,6 +187,16 @@ protected static function transformSqlBinding(mixed $binding): float|int|string
return '';

case 'object':
if (method_exists($binding, '__toString')) {
return self::escapeString((string) $binding);
}

if ($binding instanceof DateTime) {
return $binding->format('Y-m-d H:i:s');
}

return '';

case 'string':
default:
return self::escapeString((string) $binding);
Expand Down

0 comments on commit f9fbb86

Please sign in to comment.