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