Skip to content

[12.x] Make Model::currentEncrypter public #56130

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

Merged

Conversation

JaZo
Copy link
Contributor

@JaZo JaZo commented Jun 25, 2025

I'm working on custom casts that encrypt their value. To make the integration with the other encrypted casts seamless, I'm using the encrypter defined on the model. However, that can be null, so I have to fall back to the "default" encrypter. The model itself has a handy method to do this, but that's protected. By making this method public, we give users access to it, making their lives a little easier.

Before

$encrypted = ($model::$encrypter ?? Crypt::getFacadeRoot())->encrypt($value, false);

After

$encrypted = $model::currentEncrypter()->encrypt($value, false);

@taylorotwell taylorotwell merged commit 6262237 into laravel:12.x Jun 25, 2025
62 checks passed
@JaZo JaZo deleted the feature/make-model-current-encrypter-public branch June 25, 2025 10:31
mohammad-fouladgar pushed a commit to mohammad-fouladgar/framework that referenced this pull request Jul 22, 2025
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.

2 participants