handleObjects('Account', 'name', 'encrypted'); $this->handleObjects('Bill', 'name', 'name_encrypted'); $this->handleObjects('Bill', 'match', 'match_encrypted'); $this->handleObjects('Budget', 'name', 'encrypted'); $this->handleObjects('Category', 'name', 'encrypted'); $this->handleObjects('PiggyBank', 'name', 'encrypted'); $this->handleObjects('TransactionJournal', 'description', 'encrypted'); } /** * @param string $class * @param string $field * @param string $indicator */ public function handleObjects(string $class, string $field, string $indicator) { $fqn = sprintf('FireflyIII\Models\%s', $class); $encrypt = config('firefly.encryption') ? 0 : 1; $set = $fqn::where($indicator, $encrypt)->get(); foreach ($set as $entry) { $newName = $entry->$field; $entry->$field = $newName; $entry->save(); } $this->line(sprintf('Updated %d %s.', $set->count(), strtolower(Str::plural($class)))); } }