Skip to content

Commit

Permalink
Allow Uuid and Ulid in Carbon::createFromId() (#49783)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls authored Jan 22, 2024
1 parent cb9983c commit 91bc0f6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Illuminate/Support/Carbon.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ public static function setTestNow($testNow = null)
*/
public static function createFromId($id)
{
return Ulid::isValid($id)
? static::createFromInterface(Ulid::fromString($id)->getDateTime())
: static::createFromInterface(Uuid::fromString($id)->getDateTime());
if (is_string($id)) {
$id = Ulid::isValid($id) ? Ulid::fromString($id) : Uuid::fromString($id);
}

return static::createFromInterface($id->getDateTime());
}

/**
Expand Down

0 comments on commit 91bc0f6

Please sign in to comment.