diff --git a/src/Commands/EncryptCommand.php b/src/Commands/EncryptCommand.php index 117584a..ead59d4 100644 --- a/src/Commands/EncryptCommand.php +++ b/src/Commands/EncryptCommand.php @@ -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'; @@ -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(