Skip to content

Add ShouldBeEncrypted attribute#353

Open
willrowe wants to merge 3 commits intospatie:mainfrom
willrowe:feature/encrypted-attribute
Open

Add ShouldBeEncrypted attribute#353
willrowe wants to merge 3 commits intospatie:mainfrom
willrowe:feature/encrypted-attribute

Conversation

@willrowe
Copy link
Contributor

This adds a ShouldBeEncrypted attribute that can be used instead of needing to define an encrypted method:

// before
use Spatie\LaravelSettings\Settings;

class EncryptedSettings extends Settings
{
    public string $string;

    public static function encrypted(): array
    {
        return ['string'];
    }
}

// after
use Spatie\LaravelSettings\Attributes\ShouldBeEncrypted;
use Spatie\LaravelSettings\Settings;

class EncryptedSettings extends Settings
{
    #[ShouldBeEncrypted()]
    public string $string;
}

The encrypted method still works the same, any properties that have the ShouldBeEncrypted attribute will simply be merged into it.

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

Successfully merging this pull request may close these issues.

1 participant