GithubHelp home page GithubHelp logo

Comments (2)

adamhopkinson avatar adamhopkinson commented on September 25, 2024

Good question!

I wasn't aware of hashids when I wrote laravel-model-hash. I do recall the logo, so must have seen it somewhere, but I did a search before writing mine and couldn't find anything that did what I was after. I've now read through the docs, but let me know if I've misunderstood any of it in my answer below.

laravel-model-hash looks to have a different purpose to hashids - primarily that is to replace the id in urls. I could have used hashids to generate those hashes - and this would have removed the need to persist the hash in the database - but I've previously been burned when merging systems with auto-incrementing ids. If the hash is stored in the database, some of this trauma would have been avoided, particularly having to redirect urls when the hash for a record needs to resolve to a new ID (yes I understand that ids should be permanent, but sometimes the world of work isn't ideal!).

In terms of what laravel-model-hash does in addition to what hashids can do:

  • it's ready to go out-of-the-box
  • it allows full customisation of the hash (alphabet, length, hash name)
  • configuration can be taken from the default, from the provided config file or on a model-specific basis
  • it automatically switches the RouteKeyName so that the provided hash is used in route model binding instead of the id

None of this is a criticism of hashids - they just have different purposes.

from laravel-model-hash.

adamhopkinson avatar adamhopkinson commented on September 25, 2024

Reading the code for hashids, I can see that it is possible to change the length and alphabet of the generated hashes - so ignore that difference!

from laravel-model-hash.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.