Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't pass settings to ResourceCollection #121

Closed
bcorcoran opened this issue Mar 14, 2022 · 1 comment
Closed

Can't pass settings to ResourceCollection #121

bcorcoran opened this issue Mar 14, 2022 · 1 comment

Comments

@bcorcoran
Copy link

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?

@rubenvanassche
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants