mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
New feature: option to delete all meta data from your account.
This commit is contained in:
@@ -282,4 +282,12 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
return $availableBudget;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all available budgets.
|
||||
*/
|
||||
public function destroyAll(): void
|
||||
{
|
||||
$this->user->availableBudgets()->delete();
|
||||
}
|
||||
}
|
@@ -34,6 +34,12 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
interface AvailableBudgetRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Delete all available budgets.
|
||||
*/
|
||||
public function destroyAll(): void;
|
||||
|
||||
/**
|
||||
* @param AvailableBudget $availableBudget
|
||||
*/
|
||||
|
@@ -447,4 +447,16 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
|
||||
|
||||
return $limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy all budget limits.
|
||||
*/
|
||||
public function destroyAll(): void
|
||||
{
|
||||
$budgets = $this->user->budgets()->get();
|
||||
/** @var Budget $budget */
|
||||
foreach ($budgets as $budget) {
|
||||
$budget->budgetlimits()->delete();
|
||||
}
|
||||
}
|
||||
}
|
@@ -35,6 +35,12 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
interface BudgetLimitRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Destroy all budget limits.
|
||||
*/
|
||||
public function destroyAll(): void;
|
||||
|
||||
/**
|
||||
* Tells you which amount has been budgeted (for the given budgets)
|
||||
* in the selected query. Returns a positive amount as a string.
|
||||
|
@@ -23,9 +23,11 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Repositories\Budget;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
use Exception;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Models\RecurrenceTransactionMeta;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\RuleTrigger;
|
||||
use FireflyIII\Services\Internal\Destroy\BudgetDestroyService;
|
||||
@@ -341,4 +343,20 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
Log::debug(sprintf('Updated trigger %d: %s', $trigger->id, $trigger->trigger_value));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy all budgets.
|
||||
*/
|
||||
public function destroyAll(): void
|
||||
{
|
||||
$budgets = $this->getBudgets();
|
||||
/** @var Budget $budget */
|
||||
foreach ($budgets as $budget) {
|
||||
DB::table('budget_transaction')->where('budget_id', $budget->id)->delete();
|
||||
DB::table('budget_transaction_journal')->where('budget_id', $budget->id)->delete();
|
||||
RecurrenceTransactionMeta::where('name', 'budget_id')->where('value', $budget->id)->delete();
|
||||
RuleAction::where('action_type', 'set_budget')->where('action_value', $budget->id)->delete();
|
||||
$budget->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -32,6 +32,12 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
interface BudgetRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Destroy all budgets.
|
||||
*/
|
||||
public function destroyAll(): void;
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
Reference in New Issue
Block a user