spatie/laravel-settings

Can't pass settings to ResourceCollection

bcorcoran opened this issue · 1 comments

I am using this package in an SPA-based application where laravel is acting as the API.

I was trying to serve the settings as json but I wanted to serve all the properties in the DB. I tried passing the $settings instance to the ResourceCollection, but of course it did not work.

My main question is, is accessing the settings via $settings = \Spatie\LaravelSettings\Models\SettingsProperty::where('group', 'groupname')->get(); the appropriate way to get them for passing to a ResourceCollection? Or is there a more streamlined way to do it via my defined InsertnamehereSettings class?

What's the use case for passing settings objects into a ResourceCollection? You can just return a Settings object within your controller and it will be automatically transformed into a json object. If you want to combine a few different settings classes on one endpoint, then you could return them in a collection which will automatically transform them to JSON since they are Arrayable.