mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-26 02:40:43 -06:00
Fix #3953
This commit is contained in:
parent
937c11e83c
commit
7a89df749d
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Services\Internal\Update;
|
||||
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\RecurrenceTransactionMeta;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\RuleTrigger;
|
||||
use Log;
|
||||
@ -46,7 +47,7 @@ class CategoryUpdateService
|
||||
if ('testing' === config('app.env')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
|
||||
}
|
||||
if(auth()->check()) {
|
||||
if (auth()->check()) {
|
||||
$this->user = auth()->user();
|
||||
}
|
||||
}
|
||||
@ -66,6 +67,7 @@ class CategoryUpdateService
|
||||
// update triggers and actions
|
||||
$this->updateRuleTriggers($oldName, $data['name']);
|
||||
$this->updateRuleActions($oldName, $data['name']);
|
||||
$this->updateRecurrences($oldName, $data['name']);
|
||||
|
||||
return $category;
|
||||
}
|
||||
@ -120,4 +122,19 @@ class CategoryUpdateService
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $oldName
|
||||
* @param string $newName
|
||||
*/
|
||||
private function updateRecurrences(string $oldName, string $newName): void
|
||||
{
|
||||
RecurrenceTransactionMeta
|
||||
::leftJoin('recurrences_transactions', 'rt_meta.rt_id', '=', 'recurrences_transactions.id')
|
||||
->leftJoin('recurrences', 'recurrences.id', '=', 'recurrences_transactions.recurrence_id')
|
||||
->where('recurrences.user_id', $this->user->id)
|
||||
->where('rt_meta.name', 'category_name')
|
||||
->where('rt_meta.value', $oldName)
|
||||
->update(['rt_meta.value' => $newName]);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user