Browsed by
Tag: hashids

Laravel: Create Hashed ID for A Resource Using Observer

Laravel: Create Hashed ID for A Resource Using Observer

Install hashids/hashsids package Create a wrapper for hashids Create a helper for hashids Create a config file for hashids Create a migration, which add a hashslug field Create a helper to get slug name of the given class name (optional) Create an observer for hashids which monitor on creating new record – if there’s a hashslug column and it’s null, do create hashed id for the record. Register the observer to model in boot() method in your app/Providers/AppServiceProvider.php Now let’s…

Read More Read More