Skip to content

Conversation

hivokas
Copy link
Contributor

@hivokas hivokas commented Nov 3, 2020

encrypted casts have been added to Laravel recently. While this feature is extremely useful, sometimes developers may want to use the separate key to encrypt database values. Currently, that's not possible. However, this PR introduces this ability by adding Model::encryptUsing() method that accepts encrypter instance that will be used to perform encryption-related casts.

The most typical use of this would be a similar piece of code in AppServiceProvider or in a separate service provider:

use Illuminate\Database\Eloquent\Model;
use Illuminate\Encryption\Encrypter;

$databaseEncryptionKey = config('database.encryption_key');

$encrypter = new Encrypter($databaseEncryptionKey);

Model::encryptUsing($encrypter);

Illia Sakovich added 2 commits November 3, 2020 20:28
@taylorotwell taylorotwell merged commit 71dbf22 into laravel:8.x Nov 3, 2020
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