Replies: 2 comments 1 reply
-
Hi @micobarac, I did not quite understand what you mean, but you can already customize hash id generation per model. Just look this section on the config file: laravel-model-hashid/config/model-hashid.php Lines 122 to 141 in a8ea657 So if you want to have different hash for the same id for different models, just define an other salt for the model. You can customize prefix generation or define your own prefix for a model on this config section too. This is all documented on README file |
Beta Was this translation helpful? Give feedback.
-
Hi @deligoez , I have seen that configuration part. I must admit, it is a bit cumbersome to configure all module classes this way, especially in huge systems. Using the default configuration, generated raw hashid values for the same ID in different module classes should not be the same. Maybe, 3 character model prefix should be concatenated with salt before hashing, to randomize raw values a bit. $hashid = hash($value, $salt . $prefix); |
Beta Was this translation helpful? Give feedback.
-
It would be nice to include model name or prefix in hashing logics, which would provide unique hash result for same ID values in different modules:
Current comparison:
User:
id = 1
hashId = use_xLlBdZW7ZEqe7
Company
id = 1
hashid = com_xLlBdZW7ZEqe7
As you can see, hash suffix is the same for both models.
Suggestion for improvement:
userHashId = hash('use'.1);
companyHashId = hash('com'.1);
This would provide better hashing results.
Beta Was this translation helpful? Give feedback.
All reactions