Skip to content

Firefly III: a personal finances manager

Rename tagMode to tag_mode.

James Cole4a9aeb4e44a2
diff --git a/app/Factory/TagFactory.php b/app/Factory/TagFactory.php
index b3a0e376e7..bd83716720 100644
--- a/app/Factory/TagFactory.php
+++ b/app/Factory/TagFactory.php
@@ -78,7 +78,7 @@ class TagFactory
'user_id' => $this->user->id,
'user_group_id' => $this->userGroup->id,
'tag' => trim((string) $data['tag']),
- 'tagMode' => 'nothing',
+ 'tag_mode' => 'nothing',
'date' => $data['date'],
'description' => $data['description'],
'latitude' => null,
diff --git a/app/Models/Tag.php b/app/Models/Tag.php
index 6a740a3730..3af4799730 100644
--- a/app/Models/Tag.php
+++ b/app/Models/Tag.php
@@ -40,7 +40,7 @@ class Tag extends Model
use ReturnsIntegerUserIdTrait;
use SoftDeletes;
- protected $fillable = ['user_id', 'user_group_id', 'tag', 'date', 'date_tz', 'description', 'tagMode'];
+ protected $fillable = ['user_id', 'user_group_id', 'tag', 'date', 'date_tz', 'description', 'tag_mode'];
protected $hidden = ['zoomLevel', 'latitude', 'longitude'];
diff --git a/database/migrations/2025_07_10_065736_rename_tag_mode.php b/database/migrations/2025_07_10_065736_rename_tag_mode.php
new file mode 100644
index 0000000000..26efd17a93
--- /dev/null
+++ b/database/migrations/2025_07_10_065736_rename_tag_mode.php
@@ -0,0 +1,47 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration {
+ /**
+ * Run the migrations.
+ */
+ public function up(): void
+ {
+ try {
+ // normal case
+ Schema::table('tags', static function (Blueprint $table): void {
+ if (Schema::hasColumn('tags', 'tagMode') && !Schema::hasColumn('piggy_banks', 'tag_mode')) {
+ $table->renameColumn('tagMode', 'tag_mode');
+ }
+ });
+ // lower case just in case (haha)
+ Schema::table('tags', static function (Blueprint $table): void {
+ if (Schema::hasColumn('tags', 'tagmode') && !Schema::hasColumn('piggy_banks', 'tag_mode')) {
+ $table->renameColumn('tagmode', 'tag_mode');
+ }
+ });
+ } catch (RuntimeException $e) {
+ Log::error(sprintf('Could not rename column: %s', $e->getMessage()));
+ }
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ try {
+ Schema::table('tags', static function (Blueprint $table): void {
+ if (Schema::hasColumn('tags', 'tag_mode') && !Schema::hasColumn('piggy_banks', 'tagMode')) {
+ $table->renameColumn('tag_mode', 'tagMode');
+ }
+ });
+ } catch (RuntimeException $e) {
+ Log::error(sprintf('Could not rename column: %s', $e->getMessage()));
+ }
+ }
+};
diff --git a/resources/lang/en_US/form.php b/resources/lang/en_US/form.php
index 11f4f95dac..1a904a6d1b 100644
--- a/resources/lang/en_US/form.php
+++ b/resources/lang/en_US/form.php
@@ -64,7 +64,7 @@ return [
'budget_id' => 'Budget',
'bill_id' => 'Subscription',
'opening_balance' => 'Opening balance',
- 'tagMode' => 'Tag mode',
+ 'tag_mode' => 'Tag mode',
'virtual_balance' => 'Virtual balance',
diff --git a/resources/views/accounts/reconcile/show.twig b/resources/views/accounts/reconcile/show.twig
index dd503dec9c..bbcaaff3a1 100644
--- a/resources/views/accounts/reconcile/show.twig
+++ b/resources/views/accounts/reconcile/show.twig
@@ -82,13 +82,13 @@
{% for tag in journal.tags %}
<h4 style="display: inline;"><a class="label label-success" href="{{ route('tags.show',tag) }}">
- {% if tag.tagMode == 'nothing' %}
+ {% if tag.tag_mode == 'nothing' %}
<span class="fa fa-fw fa-tag"></span>
{% endif %}
- {% if tag.tagMode == 'balancingAct' %}
+ {% if tag.tag_mode == 'balancingAct' %}
<span class="fa fa-fw fa-refresh"></span>
{% endif %}
- {% if tag.tagMode == 'advancePayment' %}
+ {% if tag.tag_mode == 'advancePayment' %}
<span class="fa fa-fw fa-sort-numeric-desc"></span>
{% endif %}
{{ tag.tag }}</a>