Няма описание

UserTableSSNEncrypter.php 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. class UserTableSSNEncrypter extends Seeder {
  3. public function run()
  4. {
  5. // Disable query logging to avoid memory exhaustion
  6. DB::disableQueryLog();
  7. $this->command->info('Users SSN Encryption started');
  8. // Initiates time
  9. $time_start = microtime(true);
  10. try
  11. {
  12. $users = User::all();
  13. foreach ($users as $user)
  14. {
  15. if(strlen($user->ssn)>9)
  16. continue;
  17. DB::table('users')
  18. ->where('id', $user->id)
  19. ->update(array(
  20. 'ssn' => Crypt::encrypt($user->ssn),
  21. // 'program_id' => $program_id, //should change when I know how this info will be given
  22. // 'updated_at' => date("Y-m-d H:i:s", time()),
  23. )
  24. );
  25. // Uncomment line below to see output
  26. // $this->command->info('Encrypted ssn for '.$user->email.': '.$user->surnames.', '.$user->first_name);
  27. }
  28. }
  29. // If an exception is raised, show the message and add to error
  30. catch(Exception $e)
  31. {
  32. $this->command->info($e->getMessage());
  33. };
  34. // Stop time
  35. $time_end = microtime(true);
  36. // Display results
  37. $this->command->info('------------------------------------------------------------');
  38. }
  39. }