From c4cea2ae7a6aa0bb3f0ab7cbd1de50608bb85fd6 Mon Sep 17 00:00:00 2001 From: HolgerHatGarKeineNode Date: Sun, 7 Dec 2025 06:16:47 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20Add=20`anon`=20column?= =?UTF-8?q?=20to=20self-hosted=20services:=20Update=20views,=20models,=20f?= =?UTF-8?q?orms,=20and=20migrations=20to=20support=20anonymous=20service?= =?UTF-8?q?=20creation=20and=20display?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Livewire/Forms/ServiceForm.php | 7 +++-- app/Models/SelfHostedService.php | 1 + ...n_column_to_self_hosted_services_table.php | 28 +++++++++++++++++++ .../views/livewire/services/index.blade.php | 6 ++-- 4 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 database/migrations/2025_12_07_051247_add_anon_column_to_self_hosted_services_table.php diff --git a/app/Livewire/Forms/ServiceForm.php b/app/Livewire/Forms/ServiceForm.php index 594469c..b507352 100644 --- a/app/Livewire/Forms/ServiceForm.php +++ b/app/Livewire/Forms/ServiceForm.php @@ -73,7 +73,7 @@ class ServiceForm extends Form $this->ip = $service->ip; $this->type = $service->type?->value; $this->contact = $service->contact; - $this->anonymous = is_null($service->created_by); + $this->anonymous = $service->anon; } public function store(): SelfHostedService @@ -91,7 +91,8 @@ class ServiceForm extends Form 'url_pkdns' => $this->url_pkdns, 'ip' => $this->ip, 'contact' => $this->contact, - 'created_by' => $this->anonymous ? null : auth()->id(), + 'anon' => $this->anonymous, + 'created_by' => auth()->id(), ]); } @@ -110,7 +111,7 @@ class ServiceForm extends Form 'url_pkdns' => $this->url_pkdns, 'ip' => $this->ip, 'contact' => $this->contact, - 'created_by' => $this->anonymous ? null : ($this->service->created_by ?? auth()->id()), + 'anon' => $this->anonymous, ]); } diff --git a/app/Models/SelfHostedService.php b/app/Models/SelfHostedService.php index 03c568f..f174789 100644 --- a/app/Models/SelfHostedService.php +++ b/app/Models/SelfHostedService.php @@ -28,6 +28,7 @@ class SelfHostedService extends Model implements HasMedia 'id' => 'integer', 'created_by' => 'integer', 'type' => SelfHostedServiceType::class, + 'anon' => 'boolean', ]; protected static function booted(): void diff --git a/database/migrations/2025_12_07_051247_add_anon_column_to_self_hosted_services_table.php b/database/migrations/2025_12_07_051247_add_anon_column_to_self_hosted_services_table.php new file mode 100644 index 0000000..9a4c646 --- /dev/null +++ b/database/migrations/2025_12_07_051247_add_anon_column_to_self_hosted_services_table.php @@ -0,0 +1,28 @@ +boolean('anon')->default(false)->after('created_by'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('self_hosted_services', function (Blueprint $table) { + $table->dropColumn('anon'); + }); + } +}; diff --git a/resources/views/livewire/services/index.blade.php b/resources/views/livewire/services/index.blade.php index faf25a4..88b957b 100644 --- a/resources/views/livewire/services/index.blade.php +++ b/resources/views/livewire/services/index.blade.php @@ -159,13 +159,13 @@ class extends Component { - @if($service->createdBy) + @if($service->anon || !$service->createdBy) + {{ __('Anonymous') }} + @else
{{ Str::length($service->createdBy->name) > 20 ? Str::substr($service->createdBy->name, 0, 4) . '...' . Str::substr($service->createdBy->name, -3) : $service->createdBy->name }}
- @else - {{ __('Anonymous') }} @endif