can edit, delete and see in api autobudget

This commit is contained in:
James Cole
2020-03-14 07:01:31 +01:00
parent 2ece754927
commit 309633069c
14 changed files with 185 additions and 53 deletions

View File

@@ -49,12 +49,18 @@ class BudgetDestroyService
*/
public function destroy(Budget $budget): void
{
try {
$budget->delete();
} catch (Exception $e) { // @codeCoverageIgnore
Log::error(sprintf('Could not delete budget: %s', $e->getMessage())); // @codeCoverageIgnore
}
// also delete auto budget:
foreach ($budget->autoBudgets()->get() as $autoBudget) {
$autoBudget->delete();
}
// also delete all relations between categories and transaction journals:
DB::table('budget_transaction_journal')->where('budget_id', (int)$budget->id)->delete();