From 6e32919d36ff8529a02fecbf7e7e0b5fd7eb8e0e Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 2 Feb 2026 19:37:16 -0500 Subject: [PATCH] feat: color-coolify: store and set color on projects --- app/Livewire/Project/Edit.php | 12 ++++++- ..._03_001245_add_color_to_projects_table.php | 32 +++++++++++++++++ resources/views/livewire/dashboard.blade.php | 5 ++- .../views/livewire/project/edit.blade.php | 35 +++++++++++++++++++ .../views/livewire/project/index.blade.php | 5 ++- 5 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 database/migrations/2026_02_03_001245_add_color_to_projects_table.php diff --git a/app/Livewire/Project/Edit.php b/app/Livewire/Project/Edit.php index a2d73eb5f..eafc649cb 100644 --- a/app/Livewire/Project/Edit.php +++ b/app/Livewire/Project/Edit.php @@ -14,17 +14,25 @@ class Edit extends Component public ?string $description = null; + public ?string $color = null; + protected function rules(): array { return [ 'name' => ValidationPatterns::nameRules(), 'description' => ValidationPatterns::descriptionRules(), + 'color' => ['nullable', 'string', 'regex:/^#[0-9A-Fa-f]{6}$/'], ]; } protected function messages(): array { - return ValidationPatterns::combinedMessages(); + return array_merge( + ValidationPatterns::combinedMessages(), + [ + 'color.regex' => 'The color must be a valid hex color code (e.g., #FF5733).', + ] + ); } public function mount(string $project_uuid) @@ -44,10 +52,12 @@ class Edit extends Component $this->project->update([ 'name' => $this->name, 'description' => $this->description, + 'color' => $this->color, ]); } else { $this->name = $this->project->name; $this->description = $this->project->description; + $this->color = $this->project->color; } } diff --git a/database/migrations/2026_02_03_001245_add_color_to_projects_table.php b/database/migrations/2026_02_03_001245_add_color_to_projects_table.php new file mode 100644 index 000000000..6ab3c480b --- /dev/null +++ b/database/migrations/2026_02_03_001245_add_color_to_projects_table.php @@ -0,0 +1,32 @@ +string('color', 7)->nullable()->after('description'); + }); + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + if (Schema::hasColumn('projects', 'color')) { + Schema::table('projects', function (Blueprint $table) { + $table->dropColumn('color'); + }); + } + } +}; diff --git a/resources/views/livewire/dashboard.blade.php b/resources/views/livewire/dashboard.blade.php index a58ca0a00..c8c491ee9 100644 --- a/resources/views/livewire/dashboard.blade.php +++ b/resources/views/livewire/dashboard.blade.php @@ -35,7 +35,10 @@ @if ($projects->count() > 0)
@foreach ($projects as $project) -
+
$project->color, + ]) @if($project->color) style="border-left-color: {{ $project->color }}" @endif>
diff --git a/resources/views/livewire/project/edit.blade.php b/resources/views/livewire/project/edit.blade.php index dfaf20ed9..9375e9765 100644 --- a/resources/views/livewire/project/edit.blade.php +++ b/resources/views/livewire/project/edit.blade.php @@ -14,6 +14,41 @@
+
+ +
+ + + @if($color) + + @endif +
+
\ No newline at end of file diff --git a/resources/views/livewire/project/index.blade.php b/resources/views/livewire/project/index.blade.php index b9ee20326..b3496d175 100644 --- a/resources/views/livewire/project/index.blade.php +++ b/resources/views/livewire/project/index.blade.php @@ -13,7 +13,10 @@
All your projects are here.
@foreach ($projects as $project) -
+
$project->color, + ]) @if($project->color) style="border-left-color: {{ $project->color }}" @endif>