Reputation: 3
I have a laravel project that already been running in production but now I want to encrypt confidential data which is salary column, here is the example of my table
|id|username|email|salary|
|1|xxx|[email protected]|1000|
|2|yyy|[email protected]|2000|
I want to use laravel encryption , so how to update my existing table and continue using laravel encryption
Upvotes: 0
Views: 1161
Reputation: 908
Instead of running any query into the database I'd prefer to execute this:
$users = App\User::all();
foreach ($users as $user) {
$user->salary = encrypt($user->salary)
$user->save();
}
You'll need to add a migration to the project in order to change the salary
type field to text
Upvotes: 1