This one is for the cases where you may not want to use your incremental DB id in your url.
So if now you have something like
example.com/1
, you can use this package and encode your id to look like
example.com/Dfs24
. This way you have a layer of anonymity in front of your incremental ids.
Keep in mind though, this will not encrypt your id, it will just mask it, and someone may be able to decode it.
trait HashId { public function scopeByHashId(Builder $query, string $hash) { $query->where('id', '=', Sqids::decode($hash)[0]); } } class Order extends Model { use HashId; }