veelasky / laravel-hashid

HashId Implementation on Laravel Eloquent ORM
MIT License
42 stars 17 forks source link

Error using HashId with String Primary Key #138

Open pamungkasandono opened 1 month ago

pamungkasandono commented 1 month ago

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 commented 1 month ago

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