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

Hierarchy on setting #6

Closed
suabahasa opened this issue Nov 18, 2020 · 1 comment
Closed

Hierarchy on setting #6

suabahasa opened this issue Nov 18, 2020 · 1 comment

Comments

@suabahasa
Copy link

Hi,
Thanks for great library.
Is it possible to define hierarchy on setting's group or property?

@rubenvanassche
Copy link
Member

There's a Cast for the Spatie data-transfer-object package: https://github.com/spatie/laravel-settings/blob/master/src/SettingsCasts/DtoCast.php

You could create a DTO like this:

class PostData extends DataTransferObject
{
    public string $title;
    
    public string $body;
}

And create a settings class like this:

class GeneralSettings extends Settings
{
    public PostData $post_data;
    
    public static function group(): string
    {
        return 'general';
    }
}

Normally the DTO cast is globally registered so, that's it! Otherwise you have to check your configuration file.

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