Laravel 13 + Livewire/Volt app for managing client organizations, documents, passwords, flexible assets, virtual machines, contacts, domains, todos, shortcuts, and role-based user administration.
143 lines
6.2 KiB
PHP
143 lines
6.2 KiB
PHP
<?php
|
|
|
|
use App\Models\Domain;
|
|
use App\Models\Organization;
|
|
use Illuminate\Validation\Rule;
|
|
use Livewire\Component;
|
|
|
|
new class extends Component
|
|
{
|
|
public Organization $organization;
|
|
public ?Domain $domain = null;
|
|
|
|
public string $name = '';
|
|
public string $registrar = '';
|
|
public string $nameservers = '';
|
|
public ?string $expires_at = null;
|
|
public bool $auto_renew = false;
|
|
public string $notes = '';
|
|
|
|
public function mount(Organization $organization, ?Domain $domain = null): void
|
|
{
|
|
$this->organization = $organization;
|
|
|
|
if ($domain?->exists) {
|
|
$this->domain = $domain;
|
|
$this->name = $domain->name;
|
|
$this->registrar = $domain->registrar ?? '';
|
|
$this->nameservers = $domain->nameservers ?? '';
|
|
$this->expires_at = $domain->expires_at?->format('Y-m-d');
|
|
$this->auto_renew = (bool) $domain->auto_renew;
|
|
$this->notes = $domain->notes ?? '';
|
|
}
|
|
}
|
|
|
|
public function save(): void
|
|
{
|
|
$validated = $this->validate([
|
|
'name' => [
|
|
'required', 'string', 'max:255',
|
|
Rule::unique('domains', 'name')->ignore($this->domain?->id),
|
|
],
|
|
'registrar' => 'nullable|string|max:255',
|
|
'nameservers' => 'nullable|string',
|
|
'expires_at' => 'nullable|date',
|
|
'auto_renew' => 'boolean',
|
|
'notes' => 'nullable|string',
|
|
]);
|
|
|
|
if ($this->domain?->exists) {
|
|
$this->domain->update($validated);
|
|
session()->flash('status', "Domaine \"{$this->domain->name}\" mis à jour.");
|
|
} else {
|
|
$this->organization->domains()->create($validated);
|
|
session()->flash('status', "Domaine \"{$this->name}\" créé.");
|
|
}
|
|
|
|
$this->redirectRoute('organizations.domains.index', $this->organization, navigate: true);
|
|
}
|
|
};
|
|
?>
|
|
|
|
<div class="max-w-2xl">
|
|
<p class="text-sm text-slate-500">{{ $organization->name }}</p>
|
|
<h1 class="mb-6 text-2xl font-semibold text-slate-900">
|
|
{{ $domain?->exists ? 'Modifier le domaine' : 'Nouveau domaine' }}
|
|
</h1>
|
|
|
|
<form wire:submit="save" class="space-y-4 rounded border border-slate-200 bg-white p-6">
|
|
<div>
|
|
<label class="block text-sm font-medium text-slate-700">Nom de domaine</label>
|
|
<input type="text" wire:model="name" placeholder="example.com"
|
|
class="mt-1 w-full rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500">
|
|
@error('name') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
|
|
</div>
|
|
|
|
<div class="grid grid-cols-2 gap-4">
|
|
<div>
|
|
<label class="block text-sm font-medium text-slate-700">Bureau d'enregistrement</label>
|
|
<input type="text" wire:model="registrar" placeholder="ex. OVH, Gandi..."
|
|
class="mt-1 w-full rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-slate-700">Expire le</label>
|
|
<input type="date" wire:model="expires_at"
|
|
class="mt-1 w-full rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500">
|
|
@error('expires_at') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-medium text-slate-700">Serveurs DNS</label>
|
|
<textarea wire:model="nameservers" rows="3" placeholder="ns1.example.com ns2.example.com"
|
|
class="mt-1 w-full rounded border-slate-300 font-mono text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500"></textarea>
|
|
<p class="mt-1 text-xs text-slate-400">Un par ligne.</p>
|
|
</div>
|
|
|
|
<label class="flex items-center gap-2 text-sm text-slate-700">
|
|
<input type="checkbox" wire:model="auto_renew" class="rounded border-slate-300">
|
|
Renouvellement automatique activé
|
|
</label>
|
|
|
|
<div>
|
|
<label class="block text-sm font-medium text-slate-700">Notes</label>
|
|
<textarea wire:model="notes" rows="4"
|
|
class="mt-1 w-full rounded border-slate-300 text-sm shadow-sm focus:border-slate-500 focus:ring-slate-500"></textarea>
|
|
</div>
|
|
|
|
<div class="flex items-center gap-3 pt-2">
|
|
<button type="submit"
|
|
class="rounded bg-slate-900 px-4 py-2 text-sm font-medium text-white hover:bg-slate-700">
|
|
Enregistrer
|
|
</button>
|
|
<a href="{{ route('organizations.domains.index', $organization) }}" class="text-sm text-slate-500 hover:text-slate-900">Annuler</a>
|
|
</div>
|
|
</form>
|
|
|
|
@if ($domain?->exists && $domain->sslCertificates->isNotEmpty())
|
|
<div class="mt-8">
|
|
<h2 class="mb-3 text-sm font-semibold uppercase tracking-wide text-slate-500">Certificats SSL</h2>
|
|
<div class="overflow-hidden rounded border border-slate-200 bg-white">
|
|
<table class="min-w-full divide-y divide-slate-200 text-sm">
|
|
<thead class="bg-slate-50 text-left text-xs uppercase tracking-wide text-slate-500">
|
|
<tr>
|
|
<th class="px-4 py-2">Nom</th>
|
|
<th class="px-4 py-2">Émetteur</th>
|
|
<th class="px-4 py-2">Expiration</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-slate-100">
|
|
@foreach ($domain->sslCertificates as $cert)
|
|
<tr>
|
|
<td class="px-4 py-2 text-slate-900">{{ $cert->name }}</td>
|
|
<td class="px-4 py-2 text-slate-600">{{ $cert->issuer ?? '—' }}</td>
|
|
<td class="px-4 py-2 text-slate-600">{{ $cert->expires_at?->format('Y-m-d') ?? '—' }}</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
@endif
|
|
</div>
|