Welcome Guest, Not a member yet? Register   Sign In
settings service: retrieve all properties of a class
#1

(This post was last modified: 10-10-2023, 10:35 PM by evansharp.)

The docs don't mention (and I've been unable to hit upon) a way to retrieve all of the stored values for a whole class of properties. Is this a feature? Can I submit a request/ PR?

The use-case is pretty standard I would think: my app has a configuration page. I have created a class in App/Config to hold the defaults and want to store user changes with the convenient service. When I load the configuration page, I'd like to be able to call the service once and get all non-default saved settings in the class rather than querying the database and having to name each property specifically. Bonus points if a wildcard `get()` intelligently grabs the class defaults and overrides them with a db-saved value if extant.

Something like:
Code:
$siteName = service('settings')->get('App.[b]*[/b]');

It seems natural that this would return an associative array of the properties as k=>v.

Thoughts?
Reply


Messages In This Thread
settings service: retrieve all properties of a class - by evansharp - 10-10-2023, 10:34 PM



Theme © iAndrew 2016 - Forum software by © MyBB