Skip to content

Commit

Permalink
[feat] add table prefix to ciphersweet:encrypt command (#60)
Browse files Browse the repository at this point in the history
* [feat] add table prefix to ciphersweet:encrypt command

* [fix] fix breaking tests
  • Loading branch information
aryala7 authored Mar 13, 2024
1 parent a9390a6 commit c8961f3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Commands/EncryptCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class EncryptCommand extends Command
{
protected $signature = 'ciphersweet:encrypt {model} {newKey} {sortDirection=asc}';
protected $signature = 'ciphersweet:encrypt {model} {newKey} {sortDirection=asc} {tablename?}';

protected $description = 'Encrypt the values of a model';

Expand Down Expand Up @@ -71,9 +71,10 @@ protected function encryptModelValues(string $modelClass): void
->orderBy((new $modelClass())
->getKeyName(), $sortDirection)
->each(function (object $model) use ($modelClass, $newClass, &$updatedRows) {
$table_name = $this->argument('tablename') ?: $newClass->getTable();
$model = (array)$model;

$oldRow = new EncryptedRow(app(CipherSweetEngine::class), $newClass->getTable());
$oldRow = new EncryptedRow(app(CipherSweetEngine::class), $table_name);
$modelClass::configureCipherSweet($oldRow);

$newRow = new EncryptedRow(
Expand Down

0 comments on commit c8961f3

Please sign in to comment.