mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2025-12-14 12:06:46 +00:00
🛠️ Add anon column to self-hosted services: Update views, models, forms, and migrations to support anonymous service creation and display
This commit is contained in:
@@ -73,7 +73,7 @@ class ServiceForm extends Form
|
|||||||
$this->ip = $service->ip;
|
$this->ip = $service->ip;
|
||||||
$this->type = $service->type?->value;
|
$this->type = $service->type?->value;
|
||||||
$this->contact = $service->contact;
|
$this->contact = $service->contact;
|
||||||
$this->anonymous = is_null($service->created_by);
|
$this->anonymous = $service->anon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(): SelfHostedService
|
public function store(): SelfHostedService
|
||||||
@@ -91,7 +91,8 @@ class ServiceForm extends Form
|
|||||||
'url_pkdns' => $this->url_pkdns,
|
'url_pkdns' => $this->url_pkdns,
|
||||||
'ip' => $this->ip,
|
'ip' => $this->ip,
|
||||||
'contact' => $this->contact,
|
'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,
|
'url_pkdns' => $this->url_pkdns,
|
||||||
'ip' => $this->ip,
|
'ip' => $this->ip,
|
||||||
'contact' => $this->contact,
|
'contact' => $this->contact,
|
||||||
'created_by' => $this->anonymous ? null : ($this->service->created_by ?? auth()->id()),
|
'anon' => $this->anonymous,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class SelfHostedService extends Model implements HasMedia
|
|||||||
'id' => 'integer',
|
'id' => 'integer',
|
||||||
'created_by' => 'integer',
|
'created_by' => 'integer',
|
||||||
'type' => SelfHostedServiceType::class,
|
'type' => SelfHostedServiceType::class,
|
||||||
|
'anon' => 'boolean',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected static function booted(): void
|
protected static function booted(): void
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('self_hosted_services', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -159,13 +159,13 @@ class extends Component {
|
|||||||
</flux:table.cell>
|
</flux:table.cell>
|
||||||
|
|
||||||
<flux:table.cell>
|
<flux:table.cell>
|
||||||
@if($service->createdBy)
|
@if($service->anon || !$service->createdBy)
|
||||||
|
<span class="text-gray-500 dark:text-gray-400 italic">{{ __('Anonymous') }}</span>
|
||||||
|
@else
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<flux:avatar size="xs" src="{{ $service->createdBy->profile_photo_url }}"/>
|
<flux:avatar size="xs" src="{{ $service->createdBy->profile_photo_url }}"/>
|
||||||
<span>{{ Str::length($service->createdBy->name) > 20 ? Str::substr($service->createdBy->name, 0, 4) . '...' . Str::substr($service->createdBy->name, -3) : $service->createdBy->name }}</span>
|
<span>{{ Str::length($service->createdBy->name) > 20 ? Str::substr($service->createdBy->name, 0, 4) . '...' . Str::substr($service->createdBy->name, -3) : $service->createdBy->name }}</span>
|
||||||
</div>
|
</div>
|
||||||
@else
|
|
||||||
<span class="text-gray-500 dark:text-gray-400 italic">{{ __('Anonymous') }}</span>
|
|
||||||
@endif
|
@endif
|
||||||
</flux:table.cell>
|
</flux:table.cell>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user