settings updates, fixed
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'Documentation',
|
||||
'storage_disk' => env('DOCUMENTATION_DISK', 'public'),
|
||||
'upload_path' => env('DOCUMENTATION_UPLOAD_PATH', 'documentation'),
|
||||
'max_upload_kb' => (int) env('DOCUMENTATION_MAX_UPLOAD_KB', 20480),
|
||||
'max_markdown_import_bytes' => (int) env('DOCUMENTATION_MAX_MARKDOWN_IMPORT_BYTES', 1048576),
|
||||
'import_markdown_attachments' => true,
|
||||
'allowed_upload_mimes' => [
|
||||
'pdf',
|
||||
'doc',
|
||||
'docx',
|
||||
'xls',
|
||||
'xlsx',
|
||||
'ppt',
|
||||
'pptx',
|
||||
'txt',
|
||||
'csv',
|
||||
'md',
|
||||
'markdown',
|
||||
'png',
|
||||
'jpg',
|
||||
'jpeg',
|
||||
'webp',
|
||||
'zip',
|
||||
],
|
||||
'statuses' => [
|
||||
'draft' => 'Draft',
|
||||
'published' => 'Published',
|
||||
'archived' => 'Archived',
|
||||
],
|
||||
];
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
<?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
|
||||
{
|
||||
if (! Schema::hasTable('documentation_categories')) {
|
||||
Schema::create('documentation_categories', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->string('name', 150);
|
||||
$table->string('slug', 180)->unique();
|
||||
$table->string('icon', 80)->nullable();
|
||||
$table->string('colour', 32)->default('blue');
|
||||
$table->text('description')->nullable();
|
||||
$table->unsignedInteger('sort_order')->default(0)->index();
|
||||
$table->boolean('is_active')->default(true)->index();
|
||||
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
if (! Schema::hasTable('documentation_documents')) {
|
||||
Schema::create('documentation_documents', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('documentation_category_id')->nullable()->constrained('documentation_categories')->nullOnDelete();
|
||||
$table->string('title', 220);
|
||||
$table->string('slug', 240)->unique();
|
||||
$table->string('summary', 500)->nullable();
|
||||
$table->longText('body')->nullable();
|
||||
$table->string('status', 40)->default('draft')->index();
|
||||
$table->boolean('is_featured')->default(false)->index();
|
||||
$table->string('version', 50)->default('1.0.0');
|
||||
$table->string('reference', 100)->nullable()->index();
|
||||
$table->string('attachment_disk')->nullable();
|
||||
$table->string('attachment_path')->nullable();
|
||||
$table->string('attachment_name')->nullable();
|
||||
$table->string('attachment_mime')->nullable();
|
||||
$table->unsignedBigInteger('attachment_size')->nullable();
|
||||
$table->timestamp('published_at')->nullable()->index();
|
||||
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
if (! Schema::hasTable('documentation_attachments')) {
|
||||
Schema::create('documentation_attachments', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('documentation_document_id')->constrained('documentation_documents')->cascadeOnDelete();
|
||||
$table->string('disk')->default('public');
|
||||
$table->string('path');
|
||||
$table->string('original_name');
|
||||
$table->string('mime_type')->nullable();
|
||||
$table->unsignedBigInteger('size')->nullable();
|
||||
$table->foreignId('uploaded_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('documentation_attachments');
|
||||
Schema::dropIfExists('documentation_documents');
|
||||
Schema::dropIfExists('documentation_categories');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Documentation\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Documentation\Http\Requests\StoreDocumentationCategoryRequest;
|
||||
use Modules\Documentation\Http\Requests\UpdateDocumentationCategoryRequest;
|
||||
use Modules\Documentation\Models\DocumentationCategory;
|
||||
|
||||
class DocumentationCategoryController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display category list.
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
return view('documentation::categories.index', [
|
||||
'categories' => DocumentationCategory::query()->withCount('documents')->ordered()->paginate(15),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show create form.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('documentation::categories.create', [
|
||||
'category' => new DocumentationCategory(['colour' => 'emerald', 'is_active' => true]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a category.
|
||||
*/
|
||||
public function store(StoreDocumentationCategoryRequest $request): RedirectResponse
|
||||
{
|
||||
$data = $request->validated();
|
||||
$data['is_active'] = $request->boolean('is_active', true);
|
||||
$data['created_by'] = $request->user()?->id;
|
||||
$data['updated_by'] = $request->user()?->id;
|
||||
|
||||
DocumentationCategory::query()->create($data);
|
||||
|
||||
return redirect()->route('documentation.categories.index')->with('status', 'Category created successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show edit form.
|
||||
*/
|
||||
public function edit(DocumentationCategory $category): View
|
||||
{
|
||||
return view('documentation::categories.edit', [
|
||||
'category' => $category,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a category.
|
||||
*/
|
||||
public function update(UpdateDocumentationCategoryRequest $request, DocumentationCategory $category): RedirectResponse
|
||||
{
|
||||
$data = $request->validated();
|
||||
$data['is_active'] = $request->boolean('is_active');
|
||||
$data['updated_by'] = $request->user()?->id;
|
||||
|
||||
$category->update($data);
|
||||
|
||||
return redirect()->route('documentation.categories.index')->with('status', 'Category updated successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a category.
|
||||
*/
|
||||
public function destroy(DocumentationCategory $category): RedirectResponse
|
||||
{
|
||||
$category->delete();
|
||||
|
||||
return redirect()->route('documentation.categories.index')->with('status', 'Category deleted successfully.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Documentation\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Modules\Documentation\Http\Requests\StoreDocumentationDocumentRequest;
|
||||
use Modules\Documentation\Http\Requests\UpdateDocumentationDocumentRequest;
|
||||
use Modules\Documentation\Models\DocumentationAttachment;
|
||||
use Modules\Documentation\Models\DocumentationCategory;
|
||||
use Modules\Documentation\Models\DocumentationDocument;
|
||||
|
||||
class DocumentationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the documentation dashboard and document list.
|
||||
*/
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$query = DocumentationDocument::query()->with(['category', 'attachments'])->latest();
|
||||
|
||||
if ($request->filled('status')) {
|
||||
$query->where('status', $request->string('status')->toString());
|
||||
}
|
||||
|
||||
if ($request->filled('category')) {
|
||||
$query->where('documentation_category_id', $request->integer('category'));
|
||||
}
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$search = '%' . $request->string('search')->trim()->toString() . '%';
|
||||
$query->where(function ($builder) use ($search): void {
|
||||
$builder->where('title', 'like', $search)
|
||||
->orWhere('summary', 'like', $search)
|
||||
->orWhere('reference', 'like', $search)
|
||||
->orWhere('body', 'like', $search);
|
||||
});
|
||||
}
|
||||
|
||||
return view('documentation::documents.index', [
|
||||
'documents' => $query->paginate(15)->withQueryString(),
|
||||
'categories' => DocumentationCategory::query()->ordered()->get(),
|
||||
'featuredDocuments' => DocumentationDocument::query()->with('category')->featured()->latest()->limit(4)->get(),
|
||||
'stats' => [
|
||||
'total' => DocumentationDocument::query()->count(),
|
||||
'published' => DocumentationDocument::query()->published()->count(),
|
||||
'drafts' => DocumentationDocument::query()->where('status', DocumentationDocument::STATUS_DRAFT)->count(),
|
||||
'categories' => DocumentationCategory::query()->count(),
|
||||
],
|
||||
'statuses' => config('documentation.statuses', []),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the create document form.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('documentation::documents.create', [
|
||||
'document' => new DocumentationDocument(['status' => DocumentationDocument::STATUS_DRAFT, 'version' => '1.0.0']),
|
||||
'categories' => DocumentationCategory::query()->active()->ordered()->get(),
|
||||
'statuses' => config('documentation.statuses', []),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created document.
|
||||
*/
|
||||
public function store(StoreDocumentationDocumentRequest $request): RedirectResponse
|
||||
{
|
||||
$data = $request->validated();
|
||||
$data['is_featured'] = $request->boolean('is_featured');
|
||||
$data['created_by'] = $request->user()?->id;
|
||||
$data['updated_by'] = $request->user()?->id;
|
||||
|
||||
if ($request->hasFile('attachment')) {
|
||||
if (blank($data['body'] ?? null)) {
|
||||
$data['body'] = $this->extractMarkdownBody($request) ?: ($data['body'] ?? null);
|
||||
}
|
||||
|
||||
$data = array_merge($data, $this->storeAttachment($request));
|
||||
}
|
||||
|
||||
unset($data['attachment'], $data['attachments']);
|
||||
|
||||
$document = DocumentationDocument::query()->create($data);
|
||||
$this->storeAttachments($request, $document);
|
||||
|
||||
return redirect()->route('documentation.documents.show', $document)->with('status', 'Document created successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a document.
|
||||
*/
|
||||
public function show(DocumentationDocument $document): View
|
||||
{
|
||||
return view('documentation::documents.show', [
|
||||
'document' => $document->load(['category', 'attachments']),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the edit document form.
|
||||
*/
|
||||
public function edit(DocumentationDocument $document): View
|
||||
{
|
||||
return view('documentation::documents.edit', [
|
||||
'document' => $document->load('attachments'),
|
||||
'categories' => DocumentationCategory::query()->active()->ordered()->get(),
|
||||
'statuses' => config('documentation.statuses', []),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing document.
|
||||
*/
|
||||
public function update(UpdateDocumentationDocumentRequest $request, DocumentationDocument $document): RedirectResponse
|
||||
{
|
||||
$data = $request->validated();
|
||||
$data['is_featured'] = $request->boolean('is_featured');
|
||||
$data['updated_by'] = $request->user()?->id;
|
||||
|
||||
if ($request->boolean('remove_attachment')) {
|
||||
$this->deleteAttachment($document);
|
||||
$data = array_merge($data, $this->emptyAttachmentData());
|
||||
}
|
||||
|
||||
if ($request->hasFile('attachment')) {
|
||||
$this->deleteAttachment($document);
|
||||
|
||||
if (blank($data['body'] ?? null)) {
|
||||
$data['body'] = $this->extractMarkdownBody($request) ?: ($data['body'] ?? null);
|
||||
}
|
||||
|
||||
$data = array_merge($data, $this->storeAttachment($request));
|
||||
}
|
||||
|
||||
unset($data['attachment'], $data['attachments'], $data['remove_attachment']);
|
||||
$document->update($data);
|
||||
$this->storeAttachments($request, $document);
|
||||
|
||||
return redirect()->route('documentation.documents.show', $document)->with('status', 'Document updated successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a document.
|
||||
*/
|
||||
public function destroy(DocumentationDocument $document): RedirectResponse
|
||||
{
|
||||
$document->load('attachments');
|
||||
$this->deleteAttachment($document);
|
||||
|
||||
foreach ($document->attachments as $attachment) {
|
||||
Storage::disk($attachment->disk)->delete($attachment->path);
|
||||
$attachment->delete();
|
||||
}
|
||||
|
||||
$document->delete();
|
||||
|
||||
return redirect()->route('documentation.documents.index')->with('status', 'Document archived successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the attached document file.
|
||||
*/
|
||||
public function download(DocumentationDocument $document)
|
||||
{
|
||||
abort_if(blank($document->attachment_path), 404);
|
||||
|
||||
return Storage::disk($document->attachment_disk ?: config('documentation.storage_disk', 'public'))
|
||||
->download($document->attachment_path, $document->attachment_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Download one of the document's additional attachments.
|
||||
*/
|
||||
public function downloadAttachment(DocumentationDocument $document, DocumentationAttachment $attachment)
|
||||
{
|
||||
abort_if($attachment->documentation_document_id !== $document->id, 404);
|
||||
|
||||
return Storage::disk($attachment->disk)->download($attachment->path, $attachment->original_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete one of the document's additional attachments.
|
||||
*/
|
||||
public function destroyAttachment(DocumentationDocument $document, DocumentationAttachment $attachment): RedirectResponse
|
||||
{
|
||||
abort_if($attachment->documentation_document_id !== $document->id, 404);
|
||||
|
||||
Storage::disk($attachment->disk)->delete($attachment->path);
|
||||
$attachment->delete();
|
||||
|
||||
return redirect()->route('documentation.documents.edit', $document)->with('status', 'Attachment removed successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract body content from an uploaded Markdown file when requested.
|
||||
*/
|
||||
private function extractMarkdownBody(Request $request): ?string
|
||||
{
|
||||
if (! config('documentation.import_markdown_attachments', true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$file = $request->file('attachment');
|
||||
|
||||
if ($file === null || ! $this->isMarkdownUpload($request)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($file->getSize() > (int) config('documentation.max_markdown_import_bytes', 1048576)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$content = file_get_contents($file->getRealPath());
|
||||
|
||||
if ($content === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return trim($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the uploaded attachment is a Markdown file.
|
||||
*/
|
||||
private function isMarkdownUpload(Request $request): bool
|
||||
{
|
||||
$file = $request->file('attachment');
|
||||
|
||||
if ($file === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$extension = strtolower($file->getClientOriginalExtension());
|
||||
$mime = strtolower((string) $file->getMimeType());
|
||||
|
||||
return $extension === 'md' || in_array($mime, ['text/markdown', 'text/x-markdown'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an uploaded attachment and return persisted metadata.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function storeAttachment(Request $request): array
|
||||
{
|
||||
$file = $request->file('attachment');
|
||||
$disk = config('documentation.storage_disk', 'public');
|
||||
$path = $file->store(config('documentation.upload_path', 'documentation'), $disk);
|
||||
|
||||
return [
|
||||
'attachment_disk' => $disk,
|
||||
'attachment_path' => $path,
|
||||
'attachment_name' => $file->getClientOriginalName(),
|
||||
'attachment_mime' => $file->getMimeType(),
|
||||
'attachment_size' => $file->getSize(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Store all additional uploaded attachments for a document.
|
||||
*/
|
||||
private function storeAttachments(Request $request, DocumentationDocument $document): void
|
||||
{
|
||||
if (! $request->hasFile('attachments')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$disk = config('documentation.storage_disk', 'public');
|
||||
|
||||
foreach ((array) $request->file('attachments') as $file) {
|
||||
if ($file === null || ! $file->isValid()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$path = $file->store(config('documentation.upload_path', 'documentation'), $disk);
|
||||
|
||||
$document->attachments()->create([
|
||||
'disk' => $disk,
|
||||
'path' => $path,
|
||||
'original_name' => $file->getClientOriginalName(),
|
||||
'mime_type' => $file->getMimeType(),
|
||||
'size' => $file->getSize(),
|
||||
'uploaded_by' => $request->user()?->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a stored attachment if it exists.
|
||||
*/
|
||||
private function deleteAttachment(DocumentationDocument $document): void
|
||||
{
|
||||
if (filled($document->attachment_path)) {
|
||||
Storage::disk($document->attachment_disk ?: config('documentation.storage_disk', 'public'))->delete($document->attachment_path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty attachment metadata.
|
||||
*
|
||||
* @return array<string, null>
|
||||
*/
|
||||
private function emptyAttachmentData(): array
|
||||
{
|
||||
return [
|
||||
'attachment_disk' => null,
|
||||
'attachment_path' => null,
|
||||
'attachment_name' => null,
|
||||
'attachment_mime' => null,
|
||||
'attachment_size' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Documentation\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreDocumentationCategoryRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine whether the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:150'],
|
||||
'slug' => ['nullable', 'string', 'max:180', Rule::unique('documentation_categories', 'slug')],
|
||||
'icon' => ['nullable', 'string', 'max:80'],
|
||||
'colour' => ['required', 'string', 'max:32'],
|
||||
'description' => ['nullable', 'string', 'max:2000'],
|
||||
'sort_order' => ['nullable', 'integer', 'min:0', 'max:999999'],
|
||||
'is_active' => ['nullable', 'boolean'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Documentation\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Modules\Documentation\Models\DocumentationDocument;
|
||||
|
||||
class StoreDocumentationDocumentRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine whether the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'documentation_category_id' => ['nullable', 'integer', 'exists:documentation_categories,id'],
|
||||
'title' => ['required', 'string', 'max:220'],
|
||||
'slug' => ['nullable', 'string', 'max:240', Rule::unique('documentation_documents', 'slug')],
|
||||
'summary' => ['nullable', 'string', 'max:500'],
|
||||
'body' => ['nullable', 'string'],
|
||||
'status' => ['required', Rule::in([DocumentationDocument::STATUS_DRAFT, DocumentationDocument::STATUS_PUBLISHED, DocumentationDocument::STATUS_ARCHIVED])],
|
||||
'is_featured' => ['nullable', 'boolean'],
|
||||
'version' => ['required', 'string', 'max:50'],
|
||||
'reference' => ['nullable', 'string', 'max:100'],
|
||||
'attachment' => ['nullable', 'file', 'max:' . config('documentation.max_upload_kb', 20480), 'mimes:' . implode(',', config('documentation.allowed_upload_mimes', []))],
|
||||
'attachments' => ['nullable', 'array'],
|
||||
'attachments.*' => ['file', 'max:' . config('documentation.max_upload_kb', 20480), 'mimes:' . implode(',', config('documentation.allowed_upload_mimes', []))],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Documentation\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Modules\Documentation\Models\DocumentationCategory;
|
||||
|
||||
class UpdateDocumentationCategoryRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine whether the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
/** @var DocumentationCategory|null $category */
|
||||
$category = $this->route('category');
|
||||
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:150'],
|
||||
'slug' => ['nullable', 'string', 'max:180', Rule::unique('documentation_categories', 'slug')->ignore($category?->id)],
|
||||
'icon' => ['nullable', 'string', 'max:80'],
|
||||
'colour' => ['required', 'string', 'max:32'],
|
||||
'description' => ['nullable', 'string', 'max:2000'],
|
||||
'sort_order' => ['nullable', 'integer', 'min:0', 'max:999999'],
|
||||
'is_active' => ['nullable', 'boolean'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Documentation\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Modules\Documentation\Models\DocumentationDocument;
|
||||
|
||||
class UpdateDocumentationDocumentRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine whether the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
/** @var DocumentationDocument|null $document */
|
||||
$document = $this->route('document');
|
||||
|
||||
return [
|
||||
'documentation_category_id' => ['nullable', 'integer', 'exists:documentation_categories,id'],
|
||||
'title' => ['required', 'string', 'max:220'],
|
||||
'slug' => ['nullable', 'string', 'max:240', Rule::unique('documentation_documents', 'slug')->ignore($document?->id)],
|
||||
'summary' => ['nullable', 'string', 'max:500'],
|
||||
'body' => ['nullable', 'string'],
|
||||
'status' => ['required', Rule::in([DocumentationDocument::STATUS_DRAFT, DocumentationDocument::STATUS_PUBLISHED, DocumentationDocument::STATUS_ARCHIVED])],
|
||||
'is_featured' => ['nullable', 'boolean'],
|
||||
'version' => ['required', 'string', 'max:50'],
|
||||
'reference' => ['nullable', 'string', 'max:100'],
|
||||
'attachment' => ['nullable', 'file', 'max:' . config('documentation.max_upload_kb', 20480), 'mimes:' . implode(',', config('documentation.allowed_upload_mimes', []))],
|
||||
'attachments' => ['nullable', 'array'],
|
||||
'attachments.*' => ['file', 'max:' . config('documentation.max_upload_kb', 20480), 'mimes:' . implode(',', config('documentation.allowed_upload_mimes', []))],
|
||||
'remove_attachment' => ['nullable', 'boolean'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Documentation\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $documentation_document_id
|
||||
* @property string $disk
|
||||
* @property string $path
|
||||
* @property string $original_name
|
||||
* @property string|null $mime_type
|
||||
* @property int|null $size
|
||||
*/
|
||||
class DocumentationAttachment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/** @var list<string> */
|
||||
protected $fillable = [
|
||||
'documentation_document_id',
|
||||
'disk',
|
||||
'path',
|
||||
'original_name',
|
||||
'mime_type',
|
||||
'size',
|
||||
'uploaded_by',
|
||||
];
|
||||
|
||||
/** @var array<string, string> */
|
||||
protected $casts = [
|
||||
'size' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* Owning document.
|
||||
*
|
||||
* @return BelongsTo<DocumentationDocument, DocumentationAttachment>
|
||||
*/
|
||||
public function document(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DocumentationDocument::class, 'documentation_document_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a readable file size label.
|
||||
*/
|
||||
public function getSizeLabelAttribute(): string
|
||||
{
|
||||
$bytes = (int) $this->size;
|
||||
|
||||
if ($bytes <= 0) {
|
||||
return 'Unknown size';
|
||||
}
|
||||
|
||||
if ($bytes < 1024) {
|
||||
return $bytes . ' B';
|
||||
}
|
||||
|
||||
if ($bytes < 1048576) {
|
||||
return number_format($bytes / 1024, 1) . ' KB';
|
||||
}
|
||||
|
||||
return number_format($bytes / 1048576, 1) . ' MB';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Documentation\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $slug
|
||||
* @property string|null $icon
|
||||
* @property string $colour
|
||||
* @property string|null $description
|
||||
* @property int $sort_order
|
||||
* @property bool $is_active
|
||||
*/
|
||||
class DocumentationCategory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/** @var list<string> */
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'slug',
|
||||
'icon',
|
||||
'colour',
|
||||
'description',
|
||||
'sort_order',
|
||||
'is_active',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
/** @var array<string, string> */
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
'sort_order' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* Bootstrap the model.
|
||||
*/
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saving(function (DocumentationCategory $category): void {
|
||||
if (blank($category->slug)) {
|
||||
$category->slug = Str::slug($category->name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Documents assigned to this category.
|
||||
*
|
||||
* @return HasMany<DocumentationDocument>
|
||||
*/
|
||||
public function documents(): HasMany
|
||||
{
|
||||
return $this->hasMany(DocumentationDocument::class, 'documentation_category_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Active category scope.
|
||||
*
|
||||
* @param Builder<DocumentationCategory> $query
|
||||
*
|
||||
* @return Builder<DocumentationCategory>
|
||||
*/
|
||||
public function scopeActive(Builder $query): Builder
|
||||
{
|
||||
return $query->where('is_active', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ordered category scope.
|
||||
*
|
||||
* @param Builder<DocumentationCategory> $query
|
||||
*
|
||||
* @return Builder<DocumentationCategory>
|
||||
*/
|
||||
public function scopeOrdered(Builder $query): Builder
|
||||
{
|
||||
return $query->orderBy('sort_order')->orderBy('name');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Documentation\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int|null $documentation_category_id
|
||||
* @property string $title
|
||||
* @property string $slug
|
||||
* @property string|null $summary
|
||||
* @property string|null $body
|
||||
* @property string $status
|
||||
* @property bool $is_featured
|
||||
* @property string $version
|
||||
* @property string|null $reference
|
||||
* @property-read string $rendered_body
|
||||
*/
|
||||
class DocumentationDocument extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
|
||||
public const STATUS_DRAFT = 'draft';
|
||||
|
||||
public const STATUS_PUBLISHED = 'published';
|
||||
|
||||
public const STATUS_ARCHIVED = 'archived';
|
||||
|
||||
/** @var list<string> */
|
||||
protected $fillable = [
|
||||
'documentation_category_id',
|
||||
'title',
|
||||
'slug',
|
||||
'summary',
|
||||
'body',
|
||||
'status',
|
||||
'is_featured',
|
||||
'version',
|
||||
'reference',
|
||||
'attachment_disk',
|
||||
'attachment_path',
|
||||
'attachment_name',
|
||||
'attachment_mime',
|
||||
'attachment_size',
|
||||
'published_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
/** @var array<string, string> */
|
||||
protected $casts = [
|
||||
'is_featured' => 'boolean',
|
||||
'published_at' => 'datetime',
|
||||
'attachment_size' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* Bootstrap the model.
|
||||
*/
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saving(function (DocumentationDocument $document): void {
|
||||
if (blank($document->slug)) {
|
||||
$document->slug = Str::slug($document->title);
|
||||
}
|
||||
|
||||
if ($document->status === self::STATUS_PUBLISHED && blank($document->published_at)) {
|
||||
$document->published_at = now();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Owning category.
|
||||
*
|
||||
* @return BelongsTo<DocumentationCategory, DocumentationDocument>
|
||||
*/
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DocumentationCategory::class, 'documentation_category_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Document attachments.
|
||||
*
|
||||
* @return HasMany<DocumentationAttachment>
|
||||
*/
|
||||
public function attachments(): HasMany
|
||||
{
|
||||
return $this->hasMany(DocumentationAttachment::class, 'documentation_document_id')->latest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Published document scope.
|
||||
*
|
||||
* @param Builder<DocumentationDocument> $query
|
||||
*
|
||||
* @return Builder<DocumentationDocument>
|
||||
*/
|
||||
public function scopePublished(Builder $query): Builder
|
||||
{
|
||||
return $query->where('status', self::STATUS_PUBLISHED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Featured document scope.
|
||||
*
|
||||
* @param Builder<DocumentationDocument> $query
|
||||
*
|
||||
* @return Builder<DocumentationDocument>
|
||||
*/
|
||||
public function scopeFeatured(Builder $query): Builder
|
||||
{
|
||||
return $query->where('is_featured', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the document body as safe Markdown HTML for display.
|
||||
*/
|
||||
public function getRenderedBodyAttribute(): string
|
||||
{
|
||||
$body = trim((string) $this->body);
|
||||
|
||||
if ($body === '') {
|
||||
return '<p>No document body has been added yet.</p>';
|
||||
}
|
||||
|
||||
if (method_exists(Str::class, 'markdown')) {
|
||||
return (string) Str::markdown($body, [
|
||||
'html_input' => 'strip',
|
||||
'allow_unsafe_links' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
return '<p>' . nl2br(e($body), false) . '</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the attached file is a Markdown document.
|
||||
*/
|
||||
public function hasMarkdownAttachment(): bool
|
||||
{
|
||||
$name = strtolower((string) $this->attachment_name);
|
||||
$mime = strtolower((string) $this->attachment_mime);
|
||||
|
||||
return str_ends_with($name, '.md') || in_array($mime, ['text/markdown', 'text/x-markdown', 'text/plain'], true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Documentation\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
final class DocumentationServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register module services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
|
||||
$this->mergeConfigFrom(
|
||||
module_path('Documentation', 'Config/config.php'),
|
||||
'documentation',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap module services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerViews();
|
||||
$this->loadMigrationsFrom(module_path('Documentation', 'Database/Migrations'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register module views and anonymous components.
|
||||
*/
|
||||
private function registerViews(): void
|
||||
{
|
||||
$sourcePath = module_path('Documentation', 'Resources/views');
|
||||
$overridePath = resource_path('views/modules/documentation');
|
||||
|
||||
$this->publishes([
|
||||
$sourcePath => $overridePath,
|
||||
], ['views', 'documentation-module-views']);
|
||||
|
||||
$paths = [$sourcePath];
|
||||
|
||||
foreach (Config::get('view.paths', []) as $path) {
|
||||
if (is_dir($path . '/modules/documentation')) {
|
||||
array_unshift($paths, $path . '/modules/documentation');
|
||||
}
|
||||
}
|
||||
|
||||
$this->loadViewsFrom($paths, 'documentation');
|
||||
Blade::anonymousComponentPath($sourcePath . '/components', 'documentation');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Documentation\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The module namespace to assume when generating URLs to actions.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $moduleNamespace = 'Modules\Documentation\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Called before routes are registered.
|
||||
*
|
||||
* Register any model bindings or pattern based filters.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::middleware('web')
|
||||
->group(module_path('Documentation', '/Routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->group(module_path('Documentation', '/Routes/api.php'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
@extends('documentation::layouts.master')
|
||||
|
||||
@section('title', 'Create Category')
|
||||
|
||||
@section('content')
|
||||
<div class="doc-page">
|
||||
@include('documentation::partials.hero', [
|
||||
'title' => 'Create category',
|
||||
'subtitle' => 'Add a professional grouping for documents and operational knowledge.',
|
||||
])
|
||||
<section class="doc-card">
|
||||
<div class="doc-card-header"><strong>Category details</strong></div>
|
||||
<div class="doc-card-body">
|
||||
<form method="POST" action="{{ route('documentation.categories.store') }}">
|
||||
@include('documentation::partials.category-form')
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,20 @@
|
||||
@extends('documentation::layouts.master')
|
||||
|
||||
@section('title', 'Edit Category')
|
||||
|
||||
@section('content')
|
||||
<div class="doc-page">
|
||||
@include('documentation::partials.hero', [
|
||||
'title' => 'Edit category',
|
||||
'subtitle' => 'Update category naming, ordering, visibility, and presentation metadata.',
|
||||
])
|
||||
<section class="doc-card">
|
||||
<div class="doc-card-header"><strong>{{ $category->name }}</strong></div>
|
||||
<div class="doc-card-body">
|
||||
<form method="POST" action="{{ route('documentation.categories.update', $category) }}">
|
||||
@include('documentation::partials.category-form')
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,71 @@
|
||||
@extends('documentation::layouts.master')
|
||||
|
||||
@section('title', 'Document Categories')
|
||||
|
||||
@section('content')
|
||||
<div class="doc-page">
|
||||
@include('documentation::partials.hero', [
|
||||
'title' => 'Document categories',
|
||||
'subtitle' =>
|
||||
'Organise documents by policy, process, onboarding, operational support, or technical area.',
|
||||
])
|
||||
|
||||
@if (session('status'))
|
||||
<div class="doc-alert">{{ session('status') }}</div>
|
||||
@endif
|
||||
|
||||
<section class="doc-card">
|
||||
<div class="doc-card-header">
|
||||
<strong>Categories</strong>
|
||||
<a class="doc-button category" href="{{ route('documentation.categories.create') }}">New category</a>
|
||||
</div>
|
||||
<div class="doc-card-body">
|
||||
<table class="doc-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Description</th>
|
||||
<th>Documents</th>
|
||||
<th>Order</th>
|
||||
<th>Status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse($categories as $category)
|
||||
<tr>
|
||||
<td><strong>{{ $category->name }}</strong>
|
||||
<div class="doc-muted">{{ $category->slug }}</div>
|
||||
</td>
|
||||
<td>{{ $category->description ?: 'No description' }}</td>
|
||||
<td>{{ $category->documents_count }}</td>
|
||||
<td>{{ $category->sort_order }}</td>
|
||||
<td><span
|
||||
class="doc-badge {{ $category->is_active ? '' : 'archived' }}">{{ $category->is_active ? 'Active' : 'Inactive' }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<a class="doc-link"
|
||||
href="{{ route('documentation.categories.edit', $category) }}">Edit</a>
|
||||
<form method="POST"
|
||||
action="{{ route('documentation.categories.destroy', $category) }}"
|
||||
style="display:inline;"
|
||||
onsubmit="return confirm('Delete this category? Documents will become uncategorised.')">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="doc-button danger"
|
||||
style="border:0;cursor:pointer;margin-left:10px;">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="6" class="doc-muted">No categories found.</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
<div style="margin-top:18px;">{{ $categories->links() }}</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,20 @@
|
||||
@extends('documentation::layouts.master')
|
||||
|
||||
@section('title', 'Create Document')
|
||||
|
||||
@section('content')
|
||||
<div class="doc-page">
|
||||
@include('documentation::partials.hero', [
|
||||
'title' => 'Create document',
|
||||
'subtitle' => 'Add a controlled document, guide, policy, SOP, upload, or operational note.',
|
||||
])
|
||||
<section class="doc-card">
|
||||
<div class="doc-card-header"><strong>Document details</strong></div>
|
||||
<div class="doc-card-body">
|
||||
<form method="POST" action="{{ route('documentation.documents.store') }}" enctype="multipart/form-data">
|
||||
@include('documentation::partials.document-form')
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,30 @@
|
||||
@extends('documentation::layouts.master')
|
||||
|
||||
@section('title', 'Edit Document')
|
||||
|
||||
@section('content')
|
||||
<div class="doc-page">
|
||||
@include('documentation::partials.hero', [
|
||||
'title' => 'Edit document',
|
||||
'subtitle' => 'Maintain document metadata, workflow status, version and attachment details.',
|
||||
])
|
||||
<section class="doc-card">
|
||||
<div class="doc-card-header"><strong>{{ $document->title }}</strong></div>
|
||||
<div class="doc-card-body">
|
||||
<form method="POST" action="{{ route('documentation.documents.update', $document) }}"
|
||||
enctype="multipart/form-data">
|
||||
@include('documentation::partials.document-form')
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@foreach ($document->attachments as $attachment)
|
||||
<form id="delete-attachment-{{ $attachment->id }}" method="POST"
|
||||
action="{{ route('documentation.documents.attachments.destroy', [$document, $attachment]) }}"
|
||||
onsubmit="return confirm('Remove this attachment?')">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
</form>
|
||||
@endforeach
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,105 @@
|
||||
@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>
|
||||
</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>
|
||||
<a class="doc-button success" href="{{ route('documentation.documents.create') }}">New document</a>
|
||||
</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><a class="doc-link"
|
||||
href="{{ route('documentation.documents.edit', $document) }}">Edit</a></td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="6" class="doc-muted">No documents found.</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
<div style="margin-top:18px;">{{ $documents->links() }}</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,70 @@
|
||||
@extends('documentation::layouts.master')
|
||||
|
||||
@section('title', $document->title)
|
||||
|
||||
@section('content')
|
||||
<div class="doc-page">
|
||||
@include('documentation::partials.hero', [
|
||||
'title' => $document->title,
|
||||
'subtitle' =>
|
||||
$document->summary ?:
|
||||
'Controlled documentation record with versioning, attachments and Markdown rendering.',
|
||||
'actions' => [
|
||||
[
|
||||
'label' => 'Edit document',
|
||||
'url' => route('documentation.documents.edit', $document),
|
||||
'class' => 'primary',
|
||||
],
|
||||
[
|
||||
'label' => 'Back to documents',
|
||||
'url' => route('documentation.documents.index'),
|
||||
'class' => 'secondary',
|
||||
],
|
||||
],
|
||||
])
|
||||
|
||||
<section class="doc-card">
|
||||
<div class="doc-card-header">
|
||||
<div>
|
||||
<strong>{{ $document->reference ?: 'Document' }}</strong>
|
||||
<div class="doc-muted">Version {{ $document->version }} @if ($document->category)
|
||||
· {{ $document->category->name }}
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<span class="doc-badge {{ $document->status }}">{{ ucfirst($document->status) }}</span>
|
||||
</div>
|
||||
<div class="doc-card-body">
|
||||
<article class="doc-content">{!! $document->rendered_body !!}</article>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@if ($document->attachment_name || $document->attachments->isNotEmpty())
|
||||
<section class="doc-card" style="margin-top: 18px;">
|
||||
<div class="doc-card-header"><strong>Attachments</strong></div>
|
||||
<div class="doc-card-body">
|
||||
<div class="doc-attachment-list">
|
||||
@if ($document->attachment_name)
|
||||
<div class="doc-attachment-item">
|
||||
<div>
|
||||
<a class="doc-link"
|
||||
href="{{ route('documentation.documents.download', $document) }}">{{ $document->attachment_name }}</a>
|
||||
<span class="doc-muted">Primary file</span>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@foreach ($document->attachments as $attachment)
|
||||
<div class="doc-attachment-item">
|
||||
<div>
|
||||
<a class="doc-link"
|
||||
href="{{ route('documentation.documents.attachments.download', [$document, $attachment]) }}">{{ $attachment->original_name }}</a>
|
||||
<span class="doc-muted">{{ $attachment->size_label }}</span>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@endif
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1 @@
|
||||
@extends('documentation::documents.index')
|
||||
@@ -0,0 +1,659 @@
|
||||
<x-layouts.app>
|
||||
<style>
|
||||
:root {
|
||||
--doc-ink: #18181b;
|
||||
--doc-muted: #71717a;
|
||||
--doc-line: #e4e4e7;
|
||||
--doc-panel: #ffffff;
|
||||
--doc-soft: #f4f4f5;
|
||||
--doc-brand: #2563eb;
|
||||
--doc-brand-dark: #1d4ed8;
|
||||
--doc-accent: #059669;
|
||||
--doc-danger: #dc2626;
|
||||
--doc-warning: #d97706;
|
||||
--doc-radius: 22px;
|
||||
--doc-shadow: 0 18px 55px rgba(15, 23, 42, .10);
|
||||
}
|
||||
|
||||
html.dark {
|
||||
--doc-ink: #f4f4f5;
|
||||
--doc-muted: #a1a1aa;
|
||||
--doc-line: #3f3f46;
|
||||
--doc-panel: #18181b;
|
||||
--doc-soft: #09090b;
|
||||
--doc-shadow: 0 18px 55px rgba(0, 0, 0, .28);
|
||||
}
|
||||
|
||||
body.documentation-module {
|
||||
margin: 0;
|
||||
background: #ffffff;
|
||||
color: var(--doc-ink);
|
||||
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
html.dark body.documentation-module {
|
||||
background: #09090b;
|
||||
}
|
||||
|
||||
.doc-shell {
|
||||
max-width: 1800px;
|
||||
margin: 0 auto;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.doc-page {
|
||||
margin: 0 auto;
|
||||
max-width: 1800px;
|
||||
padding: 0;
|
||||
display: grid;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.doc-hero-wrap {
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--doc-line);
|
||||
border-radius: 1.5rem;
|
||||
background: var(--doc-panel);
|
||||
box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
|
||||
}
|
||||
|
||||
.doc-hero {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
padding: 1.75rem 1.5rem;
|
||||
color: #ffffff;
|
||||
background: linear-gradient(135deg, #020617 0%, #0f172a 48%, #172554 100%);
|
||||
}
|
||||
|
||||
.doc-hero-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.doc-hero h1 {
|
||||
margin: .5rem 0 0;
|
||||
font-size: clamp(1.875rem, 4vw, 3rem);
|
||||
line-height: 1;
|
||||
font-weight: 700;
|
||||
letter-spacing: -.04em;
|
||||
}
|
||||
|
||||
.doc-eyebrow {
|
||||
margin: 0;
|
||||
color: #bfdbfe;
|
||||
text-transform: uppercase;
|
||||
font-size: .75rem;
|
||||
letter-spacing: .28em;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.doc-hero p {
|
||||
max-width: 48rem;
|
||||
margin: .5rem 0 0;
|
||||
color: rgba(219, 234, 254, .9);
|
||||
font-size: .875rem;
|
||||
line-height: 1.65;
|
||||
}
|
||||
|
||||
.doc-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: .5rem;
|
||||
}
|
||||
|
||||
.doc-button {
|
||||
border: 1px solid transparent;
|
||||
border-radius: .75rem;
|
||||
padding: .625rem .875rem;
|
||||
font-weight: 700;
|
||||
font-size: .875rem;
|
||||
line-height: 1.25rem;
|
||||
text-decoration: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: .5rem;
|
||||
cursor: pointer;
|
||||
transition: background-color .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
|
||||
}
|
||||
|
||||
.doc-button:hover {
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.doc-button.primary,
|
||||
.doc-button.register,
|
||||
.doc-button.dark {
|
||||
background: #2563eb;
|
||||
color: #ffffff;
|
||||
border-color: #2563eb;
|
||||
box-shadow: 0 8px 18px rgba(37, 99, 235, .22);
|
||||
}
|
||||
|
||||
.doc-button.primary:hover,
|
||||
.doc-button.register:hover,
|
||||
.doc-button.dark:hover {
|
||||
background: #1d4ed8;
|
||||
border-color: #1d4ed8;
|
||||
}
|
||||
|
||||
.doc-button.secondary,
|
||||
.doc-button.category,
|
||||
.doc-button.settings {
|
||||
background: #7c3aed;
|
||||
color: #ffffff;
|
||||
border-color: #7c3aed;
|
||||
box-shadow: 0 8px 18px rgba(124, 58, 237, .22);
|
||||
}
|
||||
|
||||
.doc-button.secondary:hover,
|
||||
.doc-button.category:hover,
|
||||
.doc-button.settings:hover {
|
||||
background: #6d28d9;
|
||||
border-color: #6d28d9;
|
||||
}
|
||||
|
||||
.doc-button.light,
|
||||
.doc-button.cancel,
|
||||
.doc-button.warning {
|
||||
background: #f59e0b;
|
||||
color: #ffffff;
|
||||
border-color: #f59e0b;
|
||||
box-shadow: 0 8px 18px rgba(245, 158, 11, .22);
|
||||
}
|
||||
|
||||
.doc-button.light:hover,
|
||||
.doc-button.cancel:hover,
|
||||
.doc-button.warning:hover {
|
||||
background: #d97706;
|
||||
border-color: #d97706;
|
||||
}
|
||||
|
||||
.doc-button.success {
|
||||
background: #059669;
|
||||
color: #ffffff;
|
||||
border-color: #059669;
|
||||
box-shadow: 0 8px 18px rgba(5, 150, 105, .22);
|
||||
}
|
||||
|
||||
.doc-button.success:hover {
|
||||
background: #047857;
|
||||
border-color: #047857;
|
||||
}
|
||||
|
||||
.doc-button.danger {
|
||||
background: #dc2626;
|
||||
color: #ffffff;
|
||||
border-color: #dc2626;
|
||||
box-shadow: 0 8px 18px rgba(220, 38, 38, .22);
|
||||
}
|
||||
|
||||
.doc-button.danger:hover {
|
||||
background: #b91c1c;
|
||||
border-color: #b91c1c;
|
||||
}
|
||||
|
||||
.doc-card {
|
||||
background: var(--doc-panel);
|
||||
border: 1px solid var(--doc-line);
|
||||
border-radius: 1rem;
|
||||
box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.doc-card-header {
|
||||
padding: 1rem 1.25rem;
|
||||
border-bottom: 1px solid var(--doc-line);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.doc-card-body {
|
||||
padding: 1.25rem;
|
||||
}
|
||||
|
||||
.doc-grid {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.doc-grid.stats {
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.doc-stat {
|
||||
padding: 1.25rem;
|
||||
}
|
||||
|
||||
.doc-stat strong {
|
||||
display: block;
|
||||
font-size: 1.875rem;
|
||||
line-height: 2.25rem;
|
||||
letter-spacing: -.04em;
|
||||
color: var(--doc-ink);
|
||||
}
|
||||
|
||||
.doc-stat span {
|
||||
color: var(--doc-muted);
|
||||
font-size: .75rem;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: .08em;
|
||||
}
|
||||
|
||||
.doc-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.doc-table th {
|
||||
text-align: left;
|
||||
font-size: .75rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: .08em;
|
||||
color: var(--doc-muted);
|
||||
padding: .75rem;
|
||||
border-bottom: 1px solid var(--doc-line);
|
||||
}
|
||||
|
||||
.doc-table td {
|
||||
padding: .875rem .75rem;
|
||||
border-bottom: 1px solid var(--doc-line);
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.doc-table a,
|
||||
.doc-link {
|
||||
color: #1d4ed8;
|
||||
font-weight: 700;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
html.dark .doc-table a,
|
||||
html.dark .doc-link {
|
||||
color: #93c5fd;
|
||||
}
|
||||
|
||||
.doc-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
border-radius: 999px;
|
||||
padding: .25rem .625rem;
|
||||
font-size: .75rem;
|
||||
font-weight: 800;
|
||||
background: #dbeafe;
|
||||
color: #1e40af;
|
||||
border: 1px solid #bfdbfe;
|
||||
}
|
||||
|
||||
.doc-badge.published {
|
||||
background: #ecfdf5;
|
||||
color: #065f46;
|
||||
border-color: #a7f3d0;
|
||||
}
|
||||
|
||||
.doc-badge.draft {
|
||||
background: #f4f4f5;
|
||||
color: #52525b;
|
||||
border-color: #d4d4d8;
|
||||
}
|
||||
|
||||
.doc-badge.archived {
|
||||
background: #fef2f2;
|
||||
color: #991b1b;
|
||||
border-color: #fecaca;
|
||||
}
|
||||
|
||||
html.dark .doc-badge {
|
||||
background: rgba(37, 99, 235, .18);
|
||||
color: #bfdbfe;
|
||||
border-color: rgba(59, 130, 246, .35);
|
||||
}
|
||||
|
||||
html.dark .doc-badge.published {
|
||||
background: rgba(5, 150, 105, .18);
|
||||
color: #a7f3d0;
|
||||
border-color: rgba(16, 185, 129, .35);
|
||||
}
|
||||
|
||||
html.dark .doc-badge.draft {
|
||||
background: rgba(113, 113, 122, .18);
|
||||
color: #d4d4d8;
|
||||
border-color: rgba(161, 161, 170, .30);
|
||||
}
|
||||
|
||||
html.dark .doc-badge.archived {
|
||||
background: rgba(220, 38, 38, .16);
|
||||
color: #fecaca;
|
||||
border-color: rgba(248, 113, 113, .32);
|
||||
}
|
||||
|
||||
.doc-form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.doc-field.full {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.doc-label {
|
||||
display: block;
|
||||
font-weight: 700;
|
||||
margin-bottom: .5rem;
|
||||
font-size: .875rem;
|
||||
color: var(--doc-ink);
|
||||
}
|
||||
|
||||
.doc-input,
|
||||
.doc-select,
|
||||
.doc-textarea {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #d4d4d8;
|
||||
border-radius: .75rem;
|
||||
padding: .75rem .875rem;
|
||||
background: #ffffff;
|
||||
color: #18181b;
|
||||
font: inherit;
|
||||
box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
|
||||
}
|
||||
|
||||
.doc-input:focus,
|
||||
.doc-select:focus,
|
||||
.doc-textarea:focus {
|
||||
outline: 2px solid rgba(37, 99, 235, .24);
|
||||
border-color: #2563eb;
|
||||
}
|
||||
|
||||
html.dark .doc-input,
|
||||
html.dark .doc-select,
|
||||
html.dark .doc-textarea {
|
||||
background: #09090b;
|
||||
color: #f4f4f5;
|
||||
border-color: #3f3f46;
|
||||
}
|
||||
|
||||
.doc-textarea {
|
||||
min-height: 360px;
|
||||
line-height: 1.6;
|
||||
resize: vertical;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
}
|
||||
|
||||
.doc-editor {
|
||||
border: 1px solid #d4d4d8;
|
||||
border-radius: 1rem;
|
||||
overflow: hidden;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
html.dark .doc-editor {
|
||||
background: #09090b;
|
||||
border-color: #3f3f46;
|
||||
}
|
||||
|
||||
.doc-editor .doc-textarea {
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
min-height: 420px;
|
||||
}
|
||||
|
||||
.doc-editor-toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: .375rem;
|
||||
padding: .625rem;
|
||||
background: #f4f4f5;
|
||||
border-bottom: 1px solid var(--doc-line);
|
||||
}
|
||||
|
||||
html.dark .doc-editor-toolbar {
|
||||
background: #18181b;
|
||||
}
|
||||
|
||||
.doc-editor-toolbar button {
|
||||
border: 1px solid #d4d4d8;
|
||||
background: #ffffff;
|
||||
color: #18181b;
|
||||
border-radius: .625rem;
|
||||
padding: .45rem .625rem;
|
||||
font-weight: 800;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
html.dark .doc-editor-toolbar button {
|
||||
border-color: #3f3f46;
|
||||
background: #09090b;
|
||||
color: #f4f4f5;
|
||||
}
|
||||
|
||||
.doc-editor-toolbar button:hover,
|
||||
.doc-editor-toolbar button:focus {
|
||||
border-color: #2563eb;
|
||||
outline: 2px solid rgba(37, 99, 235, .20);
|
||||
}
|
||||
|
||||
.editor-help {
|
||||
padding: 0 .875rem .75rem;
|
||||
margin: -.25rem 0 0;
|
||||
font-size: .8125rem;
|
||||
}
|
||||
|
||||
.doc-error {
|
||||
color: #dc2626;
|
||||
font-size: .8125rem;
|
||||
margin-top: .375rem;
|
||||
}
|
||||
|
||||
.doc-alert {
|
||||
border-radius: 1rem;
|
||||
padding: .875rem 1rem;
|
||||
background: #ecfdf5;
|
||||
color: #065f46;
|
||||
border: 1px solid #a7f3d0;
|
||||
font-size: .875rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
html.dark .doc-alert {
|
||||
background: #022c22;
|
||||
color: #a7f3d0;
|
||||
border-color: #065f46;
|
||||
}
|
||||
|
||||
.doc-warning {
|
||||
border-radius: 1rem;
|
||||
padding: .875rem 1rem;
|
||||
background: #fffbeb;
|
||||
color: #92400e;
|
||||
border: 1px solid #fcd34d;
|
||||
font-size: .875rem;
|
||||
}
|
||||
|
||||
html.dark .doc-warning {
|
||||
background: #451a03;
|
||||
color: #fef3c7;
|
||||
border-color: #92400e;
|
||||
}
|
||||
|
||||
.doc-filter {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 180px 220px auto;
|
||||
gap: .75rem;
|
||||
margin-bottom: 1.125rem;
|
||||
}
|
||||
|
||||
.doc-content {
|
||||
line-height: 1.75;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.doc-content h1,
|
||||
.doc-content h2,
|
||||
.doc-content h3 {
|
||||
line-height: 1.2;
|
||||
letter-spacing: -.025em;
|
||||
margin: 1.4em 0 .55em;
|
||||
}
|
||||
|
||||
.doc-content h1 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.doc-content h2 {
|
||||
font-size: 1.55rem;
|
||||
border-bottom: 1px solid var(--doc-line);
|
||||
padding-bottom: .35rem;
|
||||
}
|
||||
|
||||
.doc-content h3 {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.doc-content p,
|
||||
.doc-content ul,
|
||||
.doc-content ol,
|
||||
.doc-content blockquote,
|
||||
.doc-content pre {
|
||||
margin: 0 0 1rem;
|
||||
}
|
||||
|
||||
.doc-content code {
|
||||
background: #f1f5f9;
|
||||
border-radius: .4375rem;
|
||||
padding: .14rem .32rem;
|
||||
font-size: .92em;
|
||||
}
|
||||
|
||||
html.dark .doc-content code {
|
||||
background: #1e293b;
|
||||
color: #e2e8f0;
|
||||
}
|
||||
|
||||
.doc-content pre {
|
||||
overflow-x: auto;
|
||||
background: #0f172a;
|
||||
color: #e2e8f0;
|
||||
border-radius: 1rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.doc-content pre code {
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.doc-content blockquote {
|
||||
border-left: 4px solid #2563eb;
|
||||
padding-left: 1rem;
|
||||
color: var(--doc-muted);
|
||||
}
|
||||
|
||||
.doc-content table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
.doc-content th,
|
||||
.doc-content td {
|
||||
border: 1px solid var(--doc-line);
|
||||
padding: .625rem .75rem;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.doc-muted {
|
||||
color: var(--doc-muted);
|
||||
}
|
||||
|
||||
.doc-attachment-list {
|
||||
display: grid;
|
||||
gap: .625rem;
|
||||
}
|
||||
|
||||
.doc-attachment-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: .875rem;
|
||||
border: 1px solid var(--doc-line);
|
||||
border-radius: .875rem;
|
||||
padding: .75rem .875rem;
|
||||
background: var(--doc-panel);
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.doc-hero-row {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 860px) {
|
||||
.doc-grid.stats {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.doc-filter,
|
||||
.doc-form-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.doc-table {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 560px) {
|
||||
.doc-grid.stats {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.doc-hero {
|
||||
padding: 1.375rem;
|
||||
border-radius: 1.375rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="mx-auto max-w-[1800px] space-y-6" dusk="documentation-module">
|
||||
@yield('content')
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('click', function(event) {
|
||||
const button = event.target.closest('[data-md-before]');
|
||||
|
||||
if (!button) {
|
||||
return;
|
||||
}
|
||||
|
||||
const editor = button.closest('[data-documentation-editor]');
|
||||
const textarea = editor ? editor.querySelector('[data-markdown-textarea]') : null;
|
||||
|
||||
if (!textarea) {
|
||||
return;
|
||||
}
|
||||
|
||||
const before = button.getAttribute('data-md-before') || '';
|
||||
const after = button.getAttribute('data-md-after') || '';
|
||||
const start = textarea.selectionStart || 0;
|
||||
const end = textarea.selectionEnd || 0;
|
||||
const selected = textarea.value.substring(start, end);
|
||||
const replacement = before + selected + after;
|
||||
|
||||
textarea.setRangeText(replacement, start, end, 'end');
|
||||
textarea.focus();
|
||||
});
|
||||
</script>
|
||||
</x-layouts.app>
|
||||
@@ -0,0 +1,61 @@
|
||||
@csrf
|
||||
@if ($category->exists)
|
||||
@method('PUT')
|
||||
@endif
|
||||
<div class="doc-form-grid">
|
||||
<div class="doc-field">
|
||||
<label class="doc-label" for="name">Name</label>
|
||||
<input class="doc-input" id="name" name="name" value="{{ old('name', $category->name) }}" required
|
||||
maxlength="150">
|
||||
@error('name')
|
||||
<div class="doc-error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="doc-field">
|
||||
<label class="doc-label" for="slug">Slug</label>
|
||||
<input class="doc-input" id="slug" name="slug" value="{{ old('slug', $category->slug) }}"
|
||||
maxlength="180" placeholder="Auto-generated when blank">
|
||||
@error('slug')
|
||||
<div class="doc-error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="doc-field">
|
||||
<label class="doc-label" for="icon">Icon</label>
|
||||
<input class="doc-input" id="icon" name="icon" value="{{ old('icon', $category->icon) }}" maxlength="80"
|
||||
placeholder="book-open, file-check, shield">
|
||||
@error('icon')
|
||||
<div class="doc-error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="doc-field">
|
||||
<label class="doc-label" for="colour">Colour</label>
|
||||
<input class="doc-input" id="colour" name="colour"
|
||||
value="{{ old('colour', $category->colour ?: 'emerald') }}" required maxlength="32">
|
||||
@error('colour')
|
||||
<div class="doc-error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="doc-field">
|
||||
<label class="doc-label" for="sort_order">Sort order</label>
|
||||
<input class="doc-input" id="sort_order" name="sort_order" type="number" min="0"
|
||||
value="{{ old('sort_order', $category->sort_order ?: 0) }}">
|
||||
@error('sort_order')
|
||||
<div class="doc-error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="doc-field" style="display:flex;align-items:end;">
|
||||
<label><input type="checkbox" name="is_active" value="1" @checked(old('is_active', $category->is_active ?? true))> Active
|
||||
category</label>
|
||||
</div>
|
||||
<div class="doc-field full">
|
||||
<label class="doc-label" for="description">Description</label>
|
||||
<textarea class="doc-textarea" id="description" name="description" style="min-height:140px;">{{ old('description', $category->description) }}</textarea>
|
||||
@error('description')
|
||||
<div class="doc-error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="doc-actions" style="margin-top:22px;">
|
||||
<button class="doc-button success" type="submit">Save category</button>
|
||||
<a class="doc-button warning" href="{{ route('documentation.categories.index') }}">Cancel</a>
|
||||
</div>
|
||||
@@ -0,0 +1,147 @@
|
||||
@csrf
|
||||
@if ($document->exists)
|
||||
@method('PUT')
|
||||
@endif
|
||||
|
||||
<div class="doc-form-grid">
|
||||
<div class="doc-field">
|
||||
<label class="doc-label" for="title">Title</label>
|
||||
<input class="doc-input" id="title" name="title" value="{{ old('title', $document->title) }}" required
|
||||
maxlength="220">
|
||||
@error('title')
|
||||
<div class="doc-error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="doc-field">
|
||||
<label class="doc-label" for="slug">Slug</label>
|
||||
<input class="doc-input" id="slug" name="slug" value="{{ old('slug', $document->slug) }}"
|
||||
maxlength="240" placeholder="Auto-generated when blank">
|
||||
@error('slug')
|
||||
<div class="doc-error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="doc-field">
|
||||
<label class="doc-label" for="documentation_category_id">Category</label>
|
||||
<select class="doc-select" id="documentation_category_id" name="documentation_category_id">
|
||||
<option value="">No category</option>
|
||||
@foreach ($categories as $category)
|
||||
<option value="{{ $category->id }}" @selected((string) old('documentation_category_id', $document->documentation_category_id) === (string) $category->id)>{{ $category->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@error('documentation_category_id')
|
||||
<div class="doc-error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="doc-field">
|
||||
<label class="doc-label" for="status">Status</label>
|
||||
<select class="doc-select" id="status" name="status" required>
|
||||
@foreach ($statuses as $value => $label)
|
||||
<option value="{{ $value }}" @selected(old('status', $document->status) === $value)>{{ $label }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@error('status')
|
||||
<div class="doc-error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="doc-field">
|
||||
<label class="doc-label" for="version">Version</label>
|
||||
<input class="doc-input" id="version" name="version"
|
||||
value="{{ old('version', $document->version ?: '1.0.0') }}" required maxlength="50">
|
||||
@error('version')
|
||||
<div class="doc-error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="doc-field">
|
||||
<label class="doc-label" for="reference">Reference</label>
|
||||
<input class="doc-input" id="reference" name="reference" value="{{ old('reference', $document->reference) }}"
|
||||
maxlength="100" placeholder="SOP-001, POL-002, etc.">
|
||||
@error('reference')
|
||||
<div class="doc-error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="doc-field full">
|
||||
<label class="doc-label" for="summary">Summary</label>
|
||||
<input class="doc-input" id="summary" name="summary" value="{{ old('summary', $document->summary) }}"
|
||||
maxlength="500">
|
||||
@error('summary')
|
||||
<div class="doc-error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="doc-field full">
|
||||
<label class="doc-label" for="body">Document body</label>
|
||||
<div class="doc-editor" data-documentation-editor>
|
||||
<div class="doc-editor-toolbar" aria-label="Markdown editor controls">
|
||||
<button type="button" data-md-before="## " data-md-after="" title="Heading">H2</button>
|
||||
<button type="button" data-md-before="**" data-md-after="**" title="Bold"><strong>B</strong></button>
|
||||
<button type="button" data-md-before="_" data-md-after="_" title="Italic"><em>I</em></button>
|
||||
<button type="button" data-md-before="> " data-md-after="" title="Quote">Quote</button>
|
||||
<button type="button" data-md-before="- " data-md-after="" title="Bullet list">List</button>
|
||||
<button type="button" data-md-before="1. " data-md-after="" title="Numbered list">1.</button>
|
||||
<button type="button" data-md-before="[" data-md-after="](https://)" title="Link">Link</button>
|
||||
<button type="button" data-md-before="`" data-md-after="`" title="Inline code">Code</button>
|
||||
<button type="button" data-md-before="```php " data-md-after=" ```" title="Code block">Code
|
||||
block</button>
|
||||
<button type="button" data-md-before="| Column | Column | | --- | --- | | Value | Value |"
|
||||
data-md-after="" title="Table">Table</button>
|
||||
</div>
|
||||
<textarea class="doc-textarea" id="body" name="body" data-markdown-textarea>{{ old('body', $document->body) }}</textarea>
|
||||
<p class="doc-muted editor-help">Markdown is supported, including fenced code blocks such as
|
||||
<code>```php</code>, tables, lists, links, and headings.
|
||||
</p>
|
||||
</div>
|
||||
@error('body')
|
||||
<div class="doc-error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="doc-field full">
|
||||
<label class="doc-label" for="attachment">Primary attachment</label>
|
||||
<input class="doc-input" id="attachment" name="attachment" type="file">
|
||||
<p class="doc-muted">Primary Markdown files can be imported into the document body when the body is blank.</p>
|
||||
@if ($document->attachment_name)
|
||||
<p class="doc-muted">Current primary file: <a class="doc-link"
|
||||
href="{{ route('documentation.documents.download', $document) }}">{{ $document->attachment_name }}</a>
|
||||
</p>
|
||||
<label><input type="checkbox" name="remove_attachment" value="1"> Remove current primary
|
||||
attachment</label>
|
||||
@endif
|
||||
@error('attachment')
|
||||
<div class="doc-error">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="doc-field full">
|
||||
<label class="doc-label" for="attachments">Additional attachments</label>
|
||||
<input class="doc-input" id="attachments" name="attachments[]" type="file" multiple>
|
||||
<p class="doc-muted">Attach supporting files such as PDFs, screenshots, spreadsheets, Word documents, Markdown,
|
||||
CSV, and images.</p>
|
||||
@error('attachments')
|
||||
<div class="doc-error">{{ $message }}</div>
|
||||
@enderror
|
||||
@error('attachments.*')
|
||||
<div class="doc-error">{{ $message }}</div>
|
||||
@enderror
|
||||
|
||||
@if ($document->exists && $document->attachments->isNotEmpty())
|
||||
<div class="doc-attachment-list" style="margin-top: 14px;">
|
||||
@foreach ($document->attachments as $attachment)
|
||||
<div class="doc-attachment-item">
|
||||
<div>
|
||||
<a class="doc-link"
|
||||
href="{{ route('documentation.documents.attachments.download', [$document, $attachment]) }}">{{ $attachment->original_name }}</a>
|
||||
<span class="doc-muted">{{ $attachment->size_label }}</span>
|
||||
</div>
|
||||
<button class="doc-button danger" type="submit"
|
||||
form="delete-attachment-{{ $attachment->id }}">Remove</button>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<div class="doc-field full">
|
||||
<label><input type="checkbox" name="is_featured" value="1" @checked(old('is_featured', $document->is_featured))> Feature this
|
||||
document on the dashboard</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="doc-actions" style="margin-top:22px;">
|
||||
<button class="doc-button success" type="submit">Save document</button>
|
||||
<a class="doc-button warning" href="{{ route('documentation.documents.index') }}">Cancel</a>
|
||||
</div>
|
||||
@@ -0,0 +1,21 @@
|
||||
<section class="doc-hero-wrap">
|
||||
<div class="doc-hero">
|
||||
<div class="doc-hero-row">
|
||||
<div>
|
||||
<p class="doc-eyebrow">{{ $eyebrow ?? 'Documentation workflow' }}</p>
|
||||
<h1>{{ $title ?? 'Documentation' }}</h1>
|
||||
<p>{{ $subtitle ?? 'Manage controlled documents, policies, guides, files, and operational knowledge in one professional workspace.' }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="doc-actions">
|
||||
<a class="doc-button success" href="{{ route('documentation.documents.create') }}" wire:navigate>Create
|
||||
document</a>
|
||||
<a class="doc-button category" href="{{ route('documentation.categories.index') }}" wire:navigate>Manage
|
||||
categories</a>
|
||||
<a class="doc-button register" href="{{ route('documentation.documents.index') }}" wire:navigate>Document
|
||||
register</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::middleware(['api', 'auth:sanctum'])
|
||||
->prefix('documentation')
|
||||
->name('api.documentation.')
|
||||
->group(function (): void {
|
||||
// Reserved for tenant-aware documentation API endpoints.
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\Documentation\Http\Controllers\DocumentationCategoryController;
|
||||
use Modules\Documentation\Http\Controllers\DocumentationController;
|
||||
|
||||
Route::middleware(['web', 'auth'])
|
||||
->prefix('documentation')
|
||||
->name('documentation.')
|
||||
->group(function (): void {
|
||||
Route::get('/', [DocumentationController::class, 'index'])->name('index');
|
||||
|
||||
Route::get('/documents', [DocumentationController::class, 'index'])->name('documents.index');
|
||||
Route::get('/documents/create', [DocumentationController::class, 'create'])->name('documents.create');
|
||||
Route::post('/documents', [DocumentationController::class, 'store'])->name('documents.store');
|
||||
Route::get('/documents/{document}', [DocumentationController::class, 'show'])->name('documents.show');
|
||||
Route::get('/documents/{document}/edit', [DocumentationController::class, 'edit'])->name('documents.edit');
|
||||
Route::put('/documents/{document}', [DocumentationController::class, 'update'])->name('documents.update');
|
||||
Route::delete('/documents/{document}', [DocumentationController::class, 'destroy'])->name('documents.destroy');
|
||||
Route::get('/documents/{document}/download', [DocumentationController::class, 'download'])->name('documents.download');
|
||||
Route::get('/documents/{document}/attachments/{attachment}/download', [DocumentationController::class, 'downloadAttachment'])->name('documents.attachments.download');
|
||||
Route::delete('/documents/{document}/attachments/{attachment}', [DocumentationController::class, 'destroyAttachment'])->name('documents.attachments.destroy');
|
||||
|
||||
Route::resource('categories', DocumentationCategoryController::class)->except(['show']);
|
||||
});
|
||||
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Documentation\Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Modules\Documentation\Models\DocumentationCategory;
|
||||
use Modules\Documentation\Models\DocumentationDocument;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DocumentationModuleTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* Add a CSRF token for projects that keep web middleware enabled during tests.
|
||||
*
|
||||
* @param array<string, mixed> $payload
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function csrfPayload(array $payload): array
|
||||
{
|
||||
return array_merge(['_token' => 'test-token'], $payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* The documentation dashboard renders for authenticated users.
|
||||
*/
|
||||
public function test_documentation_dashboard_renders(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->get(route('documentation.documents.index'))
|
||||
->assertOk()
|
||||
->assertSee('Documentation Centre');
|
||||
}
|
||||
|
||||
/**
|
||||
* Documents can be created through the CRUD endpoint.
|
||||
*/
|
||||
public function test_document_can_be_created(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$category = DocumentationCategory::query()->create([
|
||||
'name' => 'Operations',
|
||||
'slug' => 'operations',
|
||||
'colour' => 'emerald',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)->withSession(['_token' => 'test-token'])->post(route('documentation.documents.store'), $this->csrfPayload([
|
||||
'documentation_category_id' => $category->id,
|
||||
'title' => 'Goods In Process',
|
||||
'slug' => 'goods-in-process',
|
||||
'summary' => 'Inbound warehouse process.',
|
||||
'body' => 'Step-by-step goods in process.',
|
||||
'status' => DocumentationDocument::STATUS_PUBLISHED,
|
||||
'version' => '1.0.0',
|
||||
'reference' => 'SOP-001',
|
||||
'is_featured' => '1',
|
||||
]));
|
||||
|
||||
$response->assertRedirect();
|
||||
$this->assertDatabaseHas('documentation_documents', [
|
||||
'title' => 'Goods In Process',
|
||||
'status' => DocumentationDocument::STATUS_PUBLISHED,
|
||||
'reference' => 'SOP-001',
|
||||
'is_featured' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Markdown attachments are stored and imported into the document body.
|
||||
*/
|
||||
public function test_markdown_attachment_is_imported_and_rendered(): void
|
||||
{
|
||||
Storage::fake('public');
|
||||
|
||||
$user = User::factory()->create();
|
||||
$file = UploadedFile::fake()->createWithContent('goods-in.md', "# Goods In\n\n- Scan delivery note\n- Confirm quantities");
|
||||
|
||||
$response = $this->actingAs($user)->withSession(['_token' => 'test-token'])->post(route('documentation.documents.store'), $this->csrfPayload([
|
||||
'title' => 'Goods In Markdown',
|
||||
'slug' => 'goods-in-markdown',
|
||||
'summary' => 'Markdown controlled document.',
|
||||
'body' => '',
|
||||
'status' => DocumentationDocument::STATUS_PUBLISHED,
|
||||
'version' => '1.0.0',
|
||||
'attachment' => $file,
|
||||
]));
|
||||
|
||||
$response->assertRedirect();
|
||||
|
||||
$document = DocumentationDocument::query()->where('slug', 'goods-in-markdown')->firstOrFail();
|
||||
|
||||
$this->assertStringContainsString('# Goods In', (string) $document->body);
|
||||
$this->assertStringContainsString('<h1>Goods In</h1>', $document->rendered_body);
|
||||
Storage::disk('public')->assertExists($document->attachment_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiple supporting attachments can be uploaded, downloaded and removed.
|
||||
*/
|
||||
public function test_document_supports_multiple_attachments(): void
|
||||
{
|
||||
Storage::fake('public');
|
||||
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->withSession(['_token' => 'test-token'])->post(route('documentation.documents.store'), $this->csrfPayload([
|
||||
'title' => 'Attachment Pack',
|
||||
'slug' => 'attachment-pack',
|
||||
'summary' => 'Document with supporting files.',
|
||||
'body' => 'Attach evidence and supporting material.',
|
||||
'status' => DocumentationDocument::STATUS_PUBLISHED,
|
||||
'version' => '1.0.0',
|
||||
'attachments' => [
|
||||
UploadedFile::fake()->createWithContent('setup.md', "```php\necho 'ok';\n```"),
|
||||
UploadedFile::fake()->create('process.pdf', 64, 'application/pdf'),
|
||||
],
|
||||
]));
|
||||
|
||||
$response->assertRedirect();
|
||||
|
||||
$document = DocumentationDocument::query()->where('slug', 'attachment-pack')->firstOrFail();
|
||||
|
||||
$this->assertCount(2, $document->attachments()->get());
|
||||
|
||||
$attachment = $document->attachments()->where('original_name', 'setup.md')->firstOrFail();
|
||||
Storage::disk('public')->assertExists($attachment->path);
|
||||
|
||||
$this->actingAs($user)
|
||||
->get(route('documentation.documents.attachments.download', [$document, $attachment]))
|
||||
->assertOk();
|
||||
|
||||
$this->actingAs($user)
|
||||
->withSession(['_token' => 'test-token'])
|
||||
->delete(route('documentation.documents.attachments.destroy', [$document, $attachment]), ['_token' => 'test-token'])
|
||||
->assertRedirect(route('documentation.documents.edit', $document));
|
||||
|
||||
$this->assertDatabaseMissing('documentation_attachments', ['id' => $attachment->id]);
|
||||
Storage::disk('public')->assertMissing($attachment->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* The editor renders Markdown controls for code blocks and tables.
|
||||
*/
|
||||
public function test_document_editor_has_markdown_code_controls(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->get(route('documentation.documents.create'))
|
||||
->assertOk()
|
||||
->assertSee('data-documentation-editor', false)
|
||||
->assertSee('Code block')
|
||||
->assertSee('Markdown is supported');
|
||||
}
|
||||
|
||||
/**
|
||||
* Categories can be created through the CRUD endpoint.
|
||||
*/
|
||||
public function test_category_can_be_created(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user)->withSession(['_token' => 'test-token'])->post(route('documentation.categories.store'), $this->csrfPayload([
|
||||
'name' => 'Policies',
|
||||
'slug' => 'policies',
|
||||
'colour' => 'emerald',
|
||||
'description' => 'Controlled business policies.',
|
||||
'sort_order' => 1,
|
||||
'is_active' => '1',
|
||||
]))->assertRedirect(route('documentation.categories.index'));
|
||||
|
||||
$this->assertDatabaseHas('documentation_categories', [
|
||||
'name' => 'Policies',
|
||||
'slug' => 'policies',
|
||||
'is_active' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
- version: 1.6.5
|
||||
date: '2026-06-16'
|
||||
changes:
|
||||
- Reworked Helpdesk action styling so header, support, settings, table, save, reset, edit and delete buttons use reliable coloured native styling.
|
||||
- Replaced settings section card dynamic Tailwind colour classes with inline styles so card colours always render.
|
||||
- Improved Kanban board dropdown styling.
|
||||
- Hardened ticket create inputs and Select2 controls to prevent white flashes during save.
|
||||
|
||||
1.6.1:
|
||||
date: 2026-06-15
|
||||
changes:
|
||||
- Added missing Documentation RouteServiceProvider so Composer package discovery and artisan commands can boot cleanly.
|
||||
|
||||
releases:
|
||||
- version: 1.6.1
|
||||
date: 2026-06-15
|
||||
changes:
|
||||
- Fixed missing DocumentationCategoryController binding failure for documentation category routes.
|
||||
- Added explicit DocumentationServiceProvider, route files, config, and guarded migrations so the module registers cleanly in nwidart/laravel-modules.
|
||||
- Preserved WMS shell styling and Documentation CRUD/Markdown/attachment functionality.
|
||||
|
||||
1.6.2:
|
||||
date: 2026-06-15
|
||||
changes:
|
||||
- Applied explicit coloured action buttons for Documentation create, category management, register, save, cancel, filter, edit and delete actions.
|
||||
- Preserved existing Documentation CRUD, Markdown editor and attachment behaviour.
|
||||
|
||||
releases:
|
||||
- version: 1.6.2
|
||||
date: 2026-06-15
|
||||
changes:
|
||||
- Applied explicit coloured Documentation action buttons across pages and forms.
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "mpba/documentation",
|
||||
"description": "Professional documentation and document management module.",
|
||||
"type": "laravel-module",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Mark Gregory",
|
||||
"email": "mark.gregory@mpba.co.uk"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\Documentation\\": ""
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Modules\\Documentation\\Tests\\": "Tests/"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "Documentation",
|
||||
"alias": "documentation",
|
||||
"version": "1.6.5",
|
||||
"description": "Professional document management and knowledge-base module with WMS shell styling, categories, CRUD, publishing, Markdown editing/import support, code blocks, attachments, and Support navigation integration.",
|
||||
"keywords": [
|
||||
"documentation",
|
||||
"documents",
|
||||
"knowledge-base",
|
||||
"crud"
|
||||
],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\Documentation\\Providers\\DocumentationServiceProvider"
|
||||
],
|
||||
"aliases": {},
|
||||
"files": [],
|
||||
"requires": []
|
||||
}
|
||||
@@ -1005,3 +1005,263 @@ span.flatpickr-weekday {
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
|
||||
/* ==========================================================================
|
||||
Helpdesk mobile / tablet responsive layer
|
||||
Keeps the Core desktop presentation while making every Helpdesk screen
|
||||
usable on touch devices and narrow viewports.
|
||||
========================================================================== */
|
||||
|
||||
.hd-mobile-header {
|
||||
min-height: 3.75rem;
|
||||
}
|
||||
|
||||
@media (max-width: 1023px) {
|
||||
.hd-helpdesk-surface {
|
||||
max-width: 100% !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.hd-helpdesk-surface > * {
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
html,
|
||||
body {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.hd-helpdesk-surface,
|
||||
.hd-helpdesk-surface.hd-mobile-ready {
|
||||
width: 100%;
|
||||
max-width: 100% !important;
|
||||
padding-left: .75rem;
|
||||
padding-right: .75rem;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
/* Hero/page headers */
|
||||
.hd-helpdesk-surface .rounded-3xl {
|
||||
border-radius: 1.15rem;
|
||||
}
|
||||
|
||||
.hd-helpdesk-surface .bg-gradient-to-br {
|
||||
padding: 1.1rem !important;
|
||||
}
|
||||
|
||||
.hd-helpdesk-surface .bg-gradient-to-br h1 {
|
||||
font-size: 1.65rem !important;
|
||||
line-height: 1.15 !important;
|
||||
}
|
||||
|
||||
.hd-helpdesk-surface .bg-gradient-to-br p {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
|
||||
/* All action rows become thumb-friendly full-width grids. */
|
||||
.hd-helpdesk-surface .hd-btn {
|
||||
min-height: 2.75rem;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
padding-inline: .9rem;
|
||||
}
|
||||
|
||||
.hd-helpdesk-surface .bg-gradient-to-br .flex.flex-wrap.gap-2 {
|
||||
display: grid !important;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
width: 100%;
|
||||
gap: .55rem !important;
|
||||
}
|
||||
|
||||
/* Dashboard metrics */
|
||||
.hd-helpdesk-surface .grid.md\:grid-cols-2,
|
||||
.hd-helpdesk-surface .grid.lg\:grid-cols-4,
|
||||
.hd-helpdesk-surface .grid.xl\:grid-cols-4 {
|
||||
grid-template-columns: 1fr !important;
|
||||
}
|
||||
|
||||
/* Settings cards: two compact coloured cards per row, one on very small phones. */
|
||||
.hd-core-settings > .grid,
|
||||
.hd-helpdesk-surface[dusk="helpdesk-settings-manager"] > .grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
|
||||
gap: .55rem !important;
|
||||
}
|
||||
|
||||
.hd-core-settings > .grid > a,
|
||||
.hd-helpdesk-surface[dusk="helpdesk-settings-manager"] > .grid > a {
|
||||
min-width: 0;
|
||||
min-height: 4.4rem;
|
||||
padding: .75rem !important;
|
||||
border-radius: .8rem !important;
|
||||
}
|
||||
|
||||
.hd-core-settings > .grid > a .text-2xl,
|
||||
.hd-helpdesk-surface[dusk="helpdesk-settings-manager"] > .grid > a .text-2xl {
|
||||
font-size: 1.25rem !important;
|
||||
}
|
||||
|
||||
/* Configuration forms */
|
||||
.hd-core-settings form .grid,
|
||||
.hd-helpdesk-surface form .grid {
|
||||
grid-template-columns: 1fr !important;
|
||||
}
|
||||
|
||||
.hd-core-settings input,
|
||||
.hd-core-settings select,
|
||||
.hd-core-settings textarea,
|
||||
.hd-helpdesk-surface input,
|
||||
.hd-helpdesk-surface select,
|
||||
.hd-helpdesk-surface textarea {
|
||||
min-height: 2.8rem;
|
||||
font-size: 16px !important; /* prevents iOS input zoom */
|
||||
}
|
||||
|
||||
.hd-helpdesk-surface textarea {
|
||||
min-height: 8rem;
|
||||
}
|
||||
|
||||
/* Search/filter bars */
|
||||
.hd-helpdesk-surface .grid.md\:grid-cols-4,
|
||||
.hd-helpdesk-surface .grid.lg\:grid-cols-4,
|
||||
.hd-helpdesk-surface .grid.xl\:grid-cols-4 {
|
||||
grid-template-columns: 1fr !important;
|
||||
}
|
||||
|
||||
/* Tables remain usable rather than crushing columns. */
|
||||
.hd-helpdesk-surface .overflow-x-auto,
|
||||
.hd-core-settings .overflow-x-auto {
|
||||
-webkit-overflow-scrolling: touch;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
|
||||
.hd-helpdesk-surface table,
|
||||
.hd-core-settings table {
|
||||
min-width: 760px;
|
||||
}
|
||||
|
||||
.hd-helpdesk-surface th,
|
||||
.hd-helpdesk-surface td,
|
||||
.hd-core-settings th,
|
||||
.hd-core-settings td {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Ticket list table gets a slightly smaller minimum than config tables. */
|
||||
.hd-helpdesk-surface[dusk="helpdesk-ticket-index"] table {
|
||||
min-width: 680px;
|
||||
}
|
||||
|
||||
/* Action button groups wrap instead of overflowing. */
|
||||
.hd-helpdesk-surface td .flex,
|
||||
.hd-core-settings td .flex {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* Ticket show page */
|
||||
.hd-helpdesk-surface .xl\:grid-cols-\[minmax\(0\,1fr\)_20rem\],
|
||||
.hd-helpdesk-surface .lg\:grid-cols-\[minmax\(0\,1fr\)_20rem\] {
|
||||
grid-template-columns: 1fr !important;
|
||||
}
|
||||
|
||||
/* Attachments/code blocks/content */
|
||||
.hd-helpdesk-surface pre,
|
||||
.hd-helpdesk-surface code,
|
||||
.hd-helpdesk-surface .prose {
|
||||
max-width: 100%;
|
||||
overflow-x: auto;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
/* Kanban: touch-friendly horizontal lanes with scroll snapping. */
|
||||
[data-helpdesk-kanban-board] {
|
||||
display: flex !important;
|
||||
gap: .75rem !important;
|
||||
overflow-x: auto !important;
|
||||
overscroll-behavior-inline: contain;
|
||||
scroll-snap-type: x mandatory;
|
||||
scroll-padding-left: .75rem;
|
||||
padding-bottom: 1rem !important;
|
||||
margin-inline: -.75rem;
|
||||
padding-inline: .75rem;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
[data-helpdesk-kanban-board] > section {
|
||||
width: min(88vw, 330px) !important;
|
||||
min-width: min(88vw, 330px) !important;
|
||||
min-height: calc(100dvh - 16rem) !important;
|
||||
scroll-snap-align: start;
|
||||
border-radius: 1rem !important;
|
||||
}
|
||||
|
||||
[data-helpdesk-kanban-column] {
|
||||
min-height: 24rem !important;
|
||||
}
|
||||
|
||||
[data-helpdesk-kanban-ticket] {
|
||||
cursor: default !important;
|
||||
touch-action: pan-y;
|
||||
}
|
||||
|
||||
.hd-kanban-mobile-move {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Board selector */
|
||||
.hd-select-wrap,
|
||||
.hd-ticket-board-select-wrap {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
/* Modal/dialog safety */
|
||||
[role="dialog"],
|
||||
[data-flux-modal] {
|
||||
max-width: calc(100vw - 1.5rem) !important;
|
||||
max-height: calc(100dvh - 1.5rem) !important;
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 479px) {
|
||||
.hd-helpdesk-surface,
|
||||
.hd-helpdesk-surface.hd-mobile-ready {
|
||||
padding-left: .55rem;
|
||||
padding-right: .55rem;
|
||||
}
|
||||
|
||||
.hd-helpdesk-surface .bg-gradient-to-br .flex.flex-wrap.gap-2 {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.hd-core-settings > .grid,
|
||||
.hd-helpdesk-surface[dusk="helpdesk-settings-manager"] > .grid {
|
||||
grid-template-columns: 1fr !important;
|
||||
}
|
||||
|
||||
[data-helpdesk-kanban-board] > section {
|
||||
width: 91vw !important;
|
||||
min-width: 91vw !important;
|
||||
}
|
||||
|
||||
.hd-helpdesk-surface .text-3xl,
|
||||
.hd-helpdesk-surface .text-4xl {
|
||||
font-size: 1.55rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* Touch-only devices: rely on mobile status selector instead of requiring DnD. */
|
||||
@media (hover: none) and (pointer: coarse) {
|
||||
[data-helpdesk-kanban-ticket] {
|
||||
-webkit-user-drag: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.hd-kanban-mobile-move {
|
||||
display: block !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
</flux:sidebar>
|
||||
|
||||
<!-- Mobile User Menu -->
|
||||
<flux:header class="lg:hidden">
|
||||
<flux:header class="hd-mobile-header lg:hidden">
|
||||
<flux:sidebar.toggle
|
||||
class="lg:hidden"
|
||||
icon="bars-2"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="hd-helpdesk-surface mx-auto max-w-[1800px] space-y-6" dusk="helpdesk-kanban-board"
|
||||
<div class="hd-helpdesk-surface hd-mobile-ready mx-auto max-w-[1800px] space-y-6" dusk="helpdesk-kanban-board"
|
||||
wire:poll.visible.5s="refreshBoard" wire:key="helpdesk-kanban-root">
|
||||
<div
|
||||
class="overflow-hidden rounded-3xl border border-zinc-200 bg-white shadow-sm dark:border-zinc-700 dark:bg-zinc-900">
|
||||
@@ -197,6 +197,32 @@
|
||||
SLA breach</div>
|
||||
@endif
|
||||
|
||||
@can('update', $ticket)
|
||||
<div class="hd-kanban-mobile-move mt-3 md:hidden">
|
||||
<label
|
||||
for="mobile-status-{{ $ticket->id }}"
|
||||
class="mb-1.5 block text-[11px] font-bold uppercase tracking-wide text-zinc-500 dark:text-zinc-400"
|
||||
>
|
||||
Move to status
|
||||
</label>
|
||||
<select
|
||||
id="mobile-status-{{ $ticket->id }}"
|
||||
class="hd-select w-full"
|
||||
wire:change="moveTicket({{ $ticket->id }}, $event.target.value)"
|
||||
aria-label="Move {{ $ticket->reference }} to another status"
|
||||
>
|
||||
@foreach ($statuses as $mobileStatus)
|
||||
<option
|
||||
value="{{ $mobileStatus->id }}"
|
||||
@selected((int) $ticket->status_id === (int) $mobileStatus->id)
|
||||
>
|
||||
{{ $mobileStatus->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
@endcan
|
||||
|
||||
<div
|
||||
class="mt-4 flex items-center justify-between gap-2 border-t border-zinc-100 pt-3 dark:border-zinc-800">
|
||||
<a href="{{ route('helpdesk.tickets.show', $ticket) }}" wire:navigate
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
$products = collect($products ?? []);
|
||||
@endphp
|
||||
|
||||
<div class="hd-helpdesk-surface hd-core-settings space-y-4" dusk="helpdesk-settings-manager">
|
||||
<div class="hd-helpdesk-surface hd-mobile-ready hd-core-settings space-y-4" dusk="helpdesk-settings-manager">
|
||||
<div
|
||||
class="overflow-hidden rounded-2xl border border-zinc-200 bg-white shadow-sm dark:border-zinc-700 dark:bg-zinc-900">
|
||||
<div class="bg-gradient-to-br from-slate-950 via-slate-900 to-blue-950 px-5 py-5 text-white">
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
->unique()
|
||||
->implode(',');
|
||||
@endphp
|
||||
<div class="hd-helpdesk-surface space-y-6" dusk="helpdesk-ticket-create" x-data="{ helpdeskAttachmentsUploading: false }">
|
||||
<div class="hd-helpdesk-surface hd-mobile-ready space-y-6" dusk="helpdesk-ticket-create" x-data="{ helpdeskAttachmentsUploading: false }">
|
||||
@include('modules.helpdesk.partials.page-header', [
|
||||
'eyebrow' => 'Helpdesk',
|
||||
'title' => 'Create ticket',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="hd-helpdesk-surface space-y-6" dusk="helpdesk-ticket-index">
|
||||
<div class="hd-helpdesk-surface hd-mobile-ready space-y-6" dusk="helpdesk-ticket-index">
|
||||
<div
|
||||
class="overflow-hidden rounded-3xl border border-zinc-200 bg-white shadow-sm dark:border-zinc-700 dark:bg-zinc-900">
|
||||
<div class="bg-gradient-to-br from-slate-950 via-slate-900 to-blue-950 px-6 py-7 text-white">
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
@endphp
|
||||
|
||||
|
||||
<div data-dusk="helpdesk-ticket-show" dusk="helpdesk-ticket-show" class="hd-helpdesk-surface space-y-4">
|
||||
<div data-dusk="helpdesk-ticket-show" dusk="helpdesk-ticket-show" class="hd-helpdesk-surface hd-mobile-ready space-y-4">
|
||||
<div
|
||||
class="overflow-hidden rounded-2xl border border-zinc-200 bg-white shadow-sm dark:border-zinc-700 dark:bg-zinc-900">
|
||||
<div class="bg-gradient-to-br from-slate-950 via-slate-900 to-blue-950 px-5 py-4 text-white">
|
||||
|
||||
+75
-1
@@ -2,6 +2,68 @@ import { defineConfig } from 'vite';
|
||||
import laravel from 'laravel-vite-plugin';
|
||||
import { bunny } from 'laravel-vite-plugin/fonts';
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
import { existsSync, readdirSync } from 'node:fs';
|
||||
import { join, relative } from 'node:path';
|
||||
|
||||
const projectRoot = process.cwd();
|
||||
|
||||
/**
|
||||
* Discover module CSS/JS entry points.
|
||||
*
|
||||
* Supported module layouts:
|
||||
*
|
||||
* Modules/Foo/Resources/assets/css/app.css
|
||||
* Modules/Foo/Resources/assets/js/app.js
|
||||
*
|
||||
* and the lower-case equivalent:
|
||||
*
|
||||
* Modules/Foo/resources/assets/css/app.css
|
||||
* Modules/Foo/resources/assets/js/app.js
|
||||
*/
|
||||
function discoverModuleInputs() {
|
||||
const modulesPath = join(projectRoot, 'Modules');
|
||||
|
||||
if (!existsSync(modulesPath)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const inputs = [];
|
||||
|
||||
for (const moduleName of readdirSync(modulesPath)) {
|
||||
const modulePath = join(modulesPath, moduleName);
|
||||
|
||||
const candidates = [
|
||||
join(modulePath, 'Resources/assets/css/app.css'),
|
||||
join(modulePath, 'Resources/assets/js/app.js'),
|
||||
join(modulePath, 'resources/assets/css/app.css'),
|
||||
join(modulePath, 'resources/assets/js/app.js'),
|
||||
];
|
||||
|
||||
for (const candidate of candidates) {
|
||||
if (existsSync(candidate)) {
|
||||
inputs.push(relative(projectRoot, candidate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return inputs;
|
||||
}
|
||||
|
||||
const moduleInputs = discoverModuleInputs();
|
||||
|
||||
console.log('[Vite] Backend theme inputs:');
|
||||
console.log(' resources/themes/backend/assets/css/app.css');
|
||||
console.log(' resources/themes/backend/assets/js/passkeys.js');
|
||||
|
||||
if (moduleInputs.length > 0) {
|
||||
console.log('[Vite] Module inputs:');
|
||||
|
||||
for (const input of moduleInputs) {
|
||||
console.log(` ${input}`);
|
||||
}
|
||||
} else {
|
||||
console.log('[Vite] No module asset entry points discovered.');
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
@@ -9,26 +71,38 @@ export default defineConfig({
|
||||
input: [
|
||||
'resources/themes/backend/assets/css/app.css',
|
||||
'resources/themes/backend/assets/js/passkeys.js',
|
||||
...moduleInputs,
|
||||
],
|
||||
|
||||
refresh: [
|
||||
'resources/themes/backend/views/**/*.blade.php',
|
||||
'resources/themes/backend/assets/**/*',
|
||||
'Modules/Helpdesk/**/*.php',
|
||||
|
||||
'Modules/*/Resources/views/**/*.blade.php',
|
||||
'Modules/*/Resources/assets/**/*',
|
||||
'Modules/*/resources/views/**/*.blade.php',
|
||||
'Modules/*/resources/assets/**/*',
|
||||
|
||||
'Modules/**/*.php',
|
||||
],
|
||||
|
||||
fonts: [
|
||||
bunny('Instrument Sans', {
|
||||
weights: [400, 500, 600],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
|
||||
tailwindcss(),
|
||||
],
|
||||
|
||||
server: {
|
||||
cors: true,
|
||||
|
||||
watch: {
|
||||
ignored: [
|
||||
'**/storage/framework/views/**',
|
||||
'**/Modules/*/node_modules/**',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user