validate(['newDiagramName' => 'required|string|max:255']);
$emptyDiagram = <<<'XML'
XML;
$document = $this->organization->documents()->create([
'name' => $this->newDiagramName,
'type' => 'diagram',
'content' => $emptyDiagram,
'current_version' => 1,
'created_by' => auth()->id(),
]);
$document->versions()->create([
'version' => 1,
'content' => $emptyDiagram,
'created_by' => auth()->id(),
]);
$this->redirectRoute('organizations.infrastructure.edit', [$this->organization, $document], navigate: true);
}
public function delete(int $documentId): void
{
$document = $this->organization->documents()->where('type', 'diagram')->findOrFail($documentId);
$document->delete();
session()->flash('status', "Schéma « {$document->name} » supprimé.");
}
public function with(): array
{
return [
'diagrams' => $this->organization->documents()
->where('type', 'diagram')
->with('creator')
->orderBy('name')
->get(),
];
}
};
?>
Infrastructure
@if (session('status'))
{{ session('status') }}
@endif
@if ($showNewDiagram)
@endif
| Nom |
Créé par |
Mis à jour |
|
@forelse ($diagrams as $diagram)
|
🗺️ {{ $diagram->name }}
|
{{ $diagram->creator?->name ?? '—' }} |
{{ $diagram->updated_at->diffForHumans() }} |
Ouvrir
|
@empty
| Aucun schéma pour le moment. |
@endforelse