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

Error using HashId with String Primary Key #138

Open
pamungkasandono opened this issue Oct 10, 2024 · 1 comment
Open

Error using HashId with String Primary Key #138

pamungkasandono opened this issue Oct 10, 2024 · 1 comment

Comments

@pamungkasandono
Copy link

Hello,

I hope you can help me. I'm encountering the following error when using the library:

TypeError: Veelasky\LaravelHashId\Repository::idToHash(): Argument #1 ($idKey) must be of type int, string given, called in vendor\veelasky\laravel-hashid\src\Eloquent\HashableId.php on line 77.

I'm trying to use HashId with a primary key that is a string. Could you please advise on how to properly implement HashId in this scenario?

Thank you for your assistance!

@addeeandra
Copy link

Can you elaborate how you implement the string-type primary key? I think it's unnecessary to hash a string-type key.

String-type usually already strong/non-predictable, such as UUID/ULID. The goal of this package is to avoid predictable increment/integer-based key. You may explain your need so the contributors can consider it, or you can make a PR.

wdyt @muhajirinlpu

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

No branches or pull requests

2 participants