laratrust
laratrust copied to clipboard
[FEATURE] Uuid support for builtin package methods
At the moment the package can suppot UUID identifiers in there models but i really dont know if the builtin methods of the package can support the string id or only works with big incremental integer identifiers.
If the package supports this identifiers maybe not make sense this issue but if it is unsupported they you have plans to add this support or will accept a PR adding UUID support
Thanks a lot
PRs are more than welcome
@soulcodex I have one question, when you're using uuid instead of regular ids what do you usually do in the model? Like you set the $keyType, $incrementing, $primaryKey ?
That could be solved with a trait making the $keyType = "string", $primaryKey = "id" and $incrementing = false for UUID based models, i has been used your package but with my own entities implementation with UUID from Ramsey package.
It is a fairly common practice to leave $keyType, $incrementing,$primaryKey alone and use uuid for route binding (also allowing for uuid's generated ahead of time by a client or aggregate, i.e. $model->create(['uuid' => $uuid]) while continuing to use auto-incrementing indexes for internal queries wherever possible. Having done that, any pattern that requires the use of uuid should work fine with minimal breakage elsewhere.
I think @inmanturbo solution is a good way to obtain the results requested without adding complexity to the package.
In this cases I usually rely on an observer that sets the uuid during the saving event.