mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
This prevents constraint errors when the specified category has already been set.
This commit is contained in:
@@ -55,7 +55,7 @@ class SetBudget implements ActionInterface
|
||||
)->first();
|
||||
if (!is_null($budget)) {
|
||||
Log::debug('Will set budget "' . $search . '" (#' . $budget->id . ') on journal #' . $this->journal->id . '.');
|
||||
$this->journal->budgets()->save($budget);
|
||||
$this->journal->budgets()->sync([$budget->id]);
|
||||
} else {
|
||||
Log::debug('Could not find budget "' . $search . '". Failed.');
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class SetCategory implements ActionInterface
|
||||
$name = $this->action->action_value;
|
||||
$category = Category::firstOrCreateEncrypted(['name' => $name, 'user_id' => Auth::user()->id]);
|
||||
Log::debug('Will set category "' . $name . '" (#' . $category->id . ') on journal #' . $this->journal->id . '.');
|
||||
$this->journal->categories()->save($category);
|
||||
$this->journal->categories()->sync([$category->id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user