Rename tagMode to tag_mode.

This commit is contained in:
James Cole
2025-07-10 07:04:20 +02:00
parent 3886c0fbde
commit 4a9aeb4e44
5 changed files with 53 additions and 6 deletions

View File

@@ -78,7 +78,7 @@ class TagFactory
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'user_group_id' => $this->userGroup->id, 'user_group_id' => $this->userGroup->id,
'tag' => trim((string) $data['tag']), 'tag' => trim((string) $data['tag']),
'tagMode' => 'nothing', 'tag_mode' => 'nothing',
'date' => $data['date'], 'date' => $data['date'],
'description' => $data['description'], 'description' => $data['description'],
'latitude' => null, 'latitude' => null,

View File

@@ -40,7 +40,7 @@ class Tag extends Model
use ReturnsIntegerUserIdTrait; use ReturnsIntegerUserIdTrait;
use SoftDeletes; 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']; protected $hidden = ['zoomLevel', 'latitude', 'longitude'];

View File

@@ -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()));
}
}
};

View File

@@ -64,7 +64,7 @@ return [
'budget_id' => 'Budget', 'budget_id' => 'Budget',
'bill_id' => 'Subscription', 'bill_id' => 'Subscription',
'opening_balance' => 'Opening balance', 'opening_balance' => 'Opening balance',
'tagMode' => 'Tag mode', 'tag_mode' => 'Tag mode',
'virtual_balance' => 'Virtual balance', 'virtual_balance' => 'Virtual balance',

View File

@@ -82,13 +82,13 @@
{% for tag in journal.tags %} {% for tag in journal.tags %}
<h4 style="display: inline;"><a class="label label-success" href="{{ route('tags.show',tag) }}"> <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> <span class="fa fa-fw fa-tag"></span>
{% endif %} {% endif %}
{% if tag.tagMode == 'balancingAct' %} {% if tag.tag_mode == 'balancingAct' %}
<span class="fa fa-fw fa-refresh"></span> <span class="fa fa-fw fa-refresh"></span>
{% endif %} {% endif %}
{% if tag.tagMode == 'advancePayment' %} {% if tag.tag_mode == 'advancePayment' %}
<span class="fa fa-fw fa-sort-numeric-desc"></span> <span class="fa fa-fw fa-sort-numeric-desc"></span>
{% endif %} {% endif %}
{{ tag.tag }}</a> {{ tag.tag }}</a>