Disable deletion of tags if they have any budgets
MODIFY
app/Models/Tag.php
app/Models/Tag.php
@@ -23,6 +23,11 @@ class Tag extends Model
];
// Relations
+ public function budgets()
+ {
+ return $this->hasMany(Budget::class);
+ }
+
public function spendings()
{
return $this->hasMany(Spending::class);

MODIFY
resources/views/tags/index.blade.php
resources/views/tags/index.blade.php
</a>
</div>
<div class="row__column row__column--compact ml-2">
- @if ($tag->spendings->count())
+ @if ($tag->budgets->count() || $tag->spendings->count())
<i class="fas fa-trash-alt"></i>
@else
<form method="POST" action="/tags/{{ $tag->id }}">

Disable deletion of tags if they have any budgets