Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Accept time when generating ULID #46201

Merged
merged 2 commits into from
Feb 22, 2023
Merged

[10.x] Accept time when generating ULID #46201

merged 2 commits into from
Feb 22, 2023

Conversation

zepfietje
Copy link
Contributor

@zepfietje zepfietje commented Feb 21, 2023

Currently Str::ulid() doesn't accept a time, although the underlying Symfony class does have a generate method that does accept it.

When migrating models from integer IDs to ULIDs, it's nice if you can keep the creation timestamp in the ULID.
This PR enables that.

Not sure what laravel/framework uses for type declarations, so let me know if anything needs changing.

@taylorotwell
Copy link
Member

This makes the method return a string instead of a ULID object, which is a breaking change.

@taylorotwell taylorotwell marked this pull request as draft February 21, 2023 16:06
@taylorotwell
Copy link
Member

Mark this as ready for review if you want me to look again.

@zepfietje zepfietje marked this pull request as ready for review February 21, 2023 20:54
@zepfietje
Copy link
Contributor Author

Thanks, @taylorotwell, good catch!

I've updated this PR to always return a ULID object.
Still calling the constructor directly when no time is passed to prevent any performance degradation by the internal validity check.

@taylorotwell taylorotwell merged commit c99d45b into laravel:10.x Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants