rawilk / laravel-settings

Store Laravel application settings in the database.
https://randallwilk.dev/docs/laravel-settings
MIT License
197 stars 17 forks source link

Custom key/context serializers #30

Closed rawilk closed 1 year ago

rawilk commented 1 year ago

PR makes it possible to define custom serializers for both setting keys and the context object. This allows for more flexibility on how setting keys are generated.

A new context serializer is also added, called DotNotationContextSerializer. This serializer maps each context argument into {key}:{value} pairs, and then implodes them together using :: as a separator instead of using serialize like the default serializer does. It will also detect a model class if it is keyed as model, and from that it will use the model's morph class intead of full name-spaced class in the key.

Before by default, all generated setting keys were hashed with md5, however that makes searching for multiple setting keys difficult. Now there is a new key generator, called ReadableKeyGenerator, which does not hash the key at all.