mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Various code cleanup
This commit is contained in:
@@ -26,7 +26,6 @@ namespace FireflyIII\Factory;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountMeta;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -45,7 +44,7 @@ class AccountMetaFactory
|
||||
*/
|
||||
public function crud(Account $account, string $field, string $value): ?AccountMeta
|
||||
{
|
||||
/** @var AccountMeta $entry */
|
||||
/** @var AccountMeta|null $entry */
|
||||
$entry = $account->accountMeta()->where('name', $field)->first();
|
||||
// must not be an empty string:
|
||||
if ('' !== $value) {
|
||||
@@ -62,11 +61,7 @@ class AccountMetaFactory
|
||||
Log::debug(sprintf('Updated meta-field "%s":"%s" for #%d ("%s") ', $field, $value, $account->id, $account->name));
|
||||
}
|
||||
if ('' === $value && null !== $entry) {
|
||||
try {
|
||||
$entry->delete();
|
||||
} catch (QueryException $e) {
|
||||
Log::debug(sprintf('Could not delete entry: %s', $e->getMessage()));
|
||||
}
|
||||
$entry->delete();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user