Files

123 lines
6.7 KiB
PHP

@extends('documentation::layouts.master')
@section('title', 'Documentation')
@section('content')
<div class="doc-page">
@include('documentation::partials.hero', [
'title' => 'Documentation Centre',
'subtitle' =>
'Create, control, publish, and archive operational documents from a clean professional register.',
])
@if (session('status'))
<div class="doc-alert">{{ session('status') }}</div>
@endif
<section class="doc-grid stats">
<article class="doc-card doc-stat"><strong>{{ $stats['total'] }}</strong><span>Total documents</span></article>
<article class="doc-card doc-stat"><strong>{{ $stats['published'] }}</strong><span>Published</span></article>
<article class="doc-card doc-stat"><strong>{{ $stats['drafts'] }}</strong><span>Drafts</span></article>
<article class="doc-card doc-stat"><strong>{{ $stats['categories'] }}</strong><span>Categories</span></article>
<article class="doc-card doc-stat"><strong>{{ $stats['archived'] }}</strong><span>Archived</span></article>
</section>
@if ($featuredDocuments->isNotEmpty())
<section class="doc-card" style="margin-bottom:18px;">
<div class="doc-card-header"><strong>Featured documents</strong></div>
<div class="doc-card-body doc-grid" style="grid-template-columns:repeat(auto-fit,minmax(220px,1fr));">
@foreach ($featuredDocuments as $featured)
<a class="doc-card doc-card-body" style="text-decoration:none;color:inherit;box-shadow:none;"
href="{{ route('documentation.documents.show', $featured) }}">
<span class="doc-badge {{ $featured->status }}">{{ ucfirst($featured->status) }}</span>
<h3 style="margin:12px 0 6px;">{{ $featured->title }}</h3>
<p class="doc-muted" style="margin:0;">{{ $featured->summary ?: 'No summary provided.' }}</p>
</a>
@endforeach
</div>
</section>
@endif
<section class="doc-card">
<div class="doc-card-header">
<strong>Document register</strong>
<div class="doc-actions">
<a class="doc-button secondary" href="{{ route('documentation.documents.archived') }}">
Archived documents ({{ $stats['archived'] }})
</a>
<a class="doc-button success" href="{{ route('documentation.documents.create') }}">New document</a>
</div>
</div>
<div class="doc-card-body">
<form class="doc-filter" method="GET" action="{{ route('documentation.documents.index') }}">
<input class="doc-input" name="search" value="{{ request('search') }}"
placeholder="Search title, reference, summary or body">
<select class="doc-select" name="status">
<option value="">All statuses</option>
@foreach ($statuses as $value => $label)
<option value="{{ $value }}" @selected(request('status') === $value)>{{ $label }}</option>
@endforeach
</select>
<select class="doc-select" name="category">
<option value="">All categories</option>
@foreach ($categories as $category)
<option value="{{ $category->id }}" @selected((string) request('category') === (string) $category->id)>{{ $category->name }}
</option>
@endforeach
</select>
<button class="doc-button primary" type="submit">Filter</button>
</form>
<table class="doc-table">
<thead>
<tr>
<th>Document</th>
<th>Category</th>
<th>Status</th>
<th>Version</th>
<th>Updated</th>
<th></th>
</tr>
</thead>
<tbody>
@forelse($documents as $document)
<tr>
<td>
<a
href="{{ route('documentation.documents.show', $document) }}">{{ $document->title }}</a>
<div class="doc-muted">{{ $document->reference ?: 'No reference' }} ·
{{ $document->summary ?: 'No summary' }}</div>
</td>
<td>{{ $document->category?->name ?: 'Uncategorised' }}</td>
<td><span
class="doc-badge {{ $document->status }}">{{ ucfirst($document->status) }}</span>
</td>
<td>{{ $document->version }}</td>
<td>{{ $document->updated_at?->format('d M Y H:i') }}</td>
<td>
<div class="doc-actions" style="justify-content:flex-end;">
<a class="doc-button primary"
href="{{ route('documentation.documents.edit', $document) }}">Edit</a>
<form method="POST"
action="{{ route('documentation.documents.destroy', $document) }}"
onsubmit="return confirm('Archive this document? Its files will be retained and it can be restored later.')">
@csrf
@method('DELETE')
<button class="doc-button warning" type="submit">Archive</button>
</form>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="6" class="doc-muted">No documents found.</td>
</tr>
@endforelse
</tbody>
</table>
<div class="doc-pagination">{{ $documents->links() }}</div>
</div>
</section>
</div>
@endsection