documentation updates

This commit is contained in:
Mark Gregory
2026-06-15 08:06:57 +01:00
parent 2a9d25ec18
commit 5aa026d3c6
80 changed files with 591 additions and 2469 deletions
-25
View File
@@ -1,25 +0,0 @@
<?php
return [
'name' => 'Documentation',
'route_prefix' => 'documentation',
'middleware' => ['web', 'auth'],
'storage_disk' => env('DOCUMENTATION_DISK', 'public'),
'upload_path' => env('DOCUMENTATION_UPLOAD_PATH', 'documentation'),
'allowed_upload_mimes' => [
'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'md', 'csv', 'png', 'jpg', 'jpeg', 'webp',
],
'max_upload_kb' => 20480,
'import_markdown_attachments' => true,
'max_markdown_import_bytes' => 1048576,
'editor' => [
'markdown_toolbar' => true,
'supports_code_blocks' => true,
'supports_tables' => true,
],
'statuses' => [
'draft' => 'Draft',
'published' => 'Published',
'archived' => 'Archived',
],
];
@@ -1,35 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('documentation_categories', function (Blueprint $table): void {
$table->id();
$table->string('name')->comment('Human-readable category name.');
$table->string('slug')->unique()->comment('URL-safe category identifier.');
$table->string('icon')->nullable()->comment('Optional UI icon class or key.');
$table->string('colour', 32)->default('emerald')->comment('Display colour token.');
$table->text('description')->nullable()->comment('Category description shown in the documentation UI.');
$table->unsignedInteger('sort_order')->default(0)->index()->comment('Manual display order.');
$table->boolean('is_active')->default(true)->index()->comment('Whether the category is visible and usable.');
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete()->comment('User that created the category.');
$table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete()->comment('Last user that updated the category.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('documentation_categories');
}
};
@@ -1,47 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('documentation_documents', function (Blueprint $table): void {
$table->id();
$table->foreignId('documentation_category_id')->nullable()->constrained('documentation_categories')->nullOnDelete()->comment('Optional owning documentation category.');
$table->string('title')->comment('Document title.');
$table->string('slug')->unique()->comment('URL-safe document identifier.');
$table->string('summary', 500)->nullable()->comment('Short document summary.');
$table->longText('body')->nullable()->comment('Full document body, markdown or HTML-safe text depending on editor implementation.');
$table->string('status', 32)->default('draft')->index()->comment('Workflow status: draft, published, or archived.');
$table->boolean('is_featured')->default(false)->index()->comment('Whether this document is highlighted on the documentation dashboard.');
$table->string('version', 50)->default('1.0.0')->comment('Document version label.');
$table->string('reference', 100)->nullable()->index()->comment('Optional business reference or document code.');
$table->string('attachment_disk')->nullable()->comment('Storage disk used for the attached file.');
$table->string('attachment_path')->nullable()->comment('Storage path for the attached file.');
$table->string('attachment_name')->nullable()->comment('Original uploaded file name.');
$table->string('attachment_mime')->nullable()->comment('Uploaded file MIME type.');
$table->unsignedBigInteger('attachment_size')->nullable()->comment('Uploaded file size in bytes.');
$table->timestamp('published_at')->nullable()->index()->comment('Date/time the document was published.');
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete()->comment('User that created the document.');
$table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete()->comment('Last user that updated the document.');
$table->timestamps();
$table->softDeletes();
$table->index(['status', 'is_featured']);
$table->index(['documentation_category_id', 'status']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('documentation_documents');
}
};
@@ -1,35 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('documentation_attachments', function (Blueprint $table): void {
$table->id();
$table->foreignId('documentation_document_id')->constrained('documentation_documents')->cascadeOnDelete()->comment('Owning documentation document.');
$table->string('disk')->comment('Storage disk used for the uploaded attachment.');
$table->string('path')->comment('Storage path for the uploaded attachment.');
$table->string('original_name')->comment('Original uploaded file name.');
$table->string('mime_type')->nullable()->comment('Uploaded file MIME type.');
$table->unsignedBigInteger('size')->nullable()->comment('Uploaded file size in bytes.');
$table->foreignId('uploaded_by')->nullable()->constrained('users')->nullOnDelete()->comment('User that uploaded the attachment.');
$table->timestamps();
$table->index(['documentation_document_id', 'created_at']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('documentation_attachments');
}
};
@@ -1,82 +0,0 @@
<?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.');
}
}
@@ -1,320 +0,0 @@
<?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\DocumentationCategory;
use Modules\Documentation\Models\DocumentationDocument;
use Modules\Documentation\Models\DocumentationAttachment;
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,
];
}
}
@@ -1,35 +0,0 @@
<?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'],
];
}
}
@@ -1,41 +0,0 @@
<?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', []))],
];
}
}
@@ -1,39 +0,0 @@
<?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'],
];
}
}
@@ -1,45 +0,0 @@
<?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'],
];
}
}
@@ -1,69 +0,0 @@
<?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';
}
}
@@ -1,87 +0,0 @@
<?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');
}
}
@@ -1,152 +0,0 @@
<?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);
}
}
@@ -1,67 +0,0 @@
<?php
namespace Modules\Documentation\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
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'));
}
}
@@ -1,18 +0,0 @@
@extends('documentation::layouts.master')
@section('title', 'Create Category')
@section('content')
@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>
@endsection
@@ -1,18 +0,0 @@
@extends('documentation::layouts.master')
@section('title', 'Edit Category')
@section('content')
@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>
@endsection
@@ -1,57 +0,0 @@
@extends('documentation::layouts.master')
@section('title', 'Document Categories')
@section('content')
@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 dark" 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-link" style="border:0;background:none;cursor:pointer;padding:0;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>
@endsection
@@ -1,18 +0,0 @@
@extends('documentation::layouts.master')
@section('title', 'Create Document')
@section('content')
@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>
@endsection
@@ -1,25 +0,0 @@
@extends('documentation::layouts.master')
@section('title', 'Edit Document')
@section('content')
@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
@endsection
@@ -1,92 +0,0 @@
@extends('documentation::layouts.master')
@section('title', 'Documentation')
@section('content')
@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 dark" 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 light" 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>
@endsection
@@ -1,53 +0,0 @@
@extends('documentation::layouts.master')
@section('title', $document->title)
@section('content')
@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
@endsection
@@ -1 +0,0 @@
@extends('documentation::documents.index')
@@ -1,141 +0,0 @@
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ trim($__env->yieldContent('title', 'Documentation')) }} - {{ config('app.name', 'Laravel') }}</title>
<style>
:root {
--doc-ink: #10231f;
--doc-muted: #64748b;
--doc-line: #dbe7e2;
--doc-panel: #ffffff;
--doc-soft: #f5faf8;
--doc-brand: #0f766e;
--doc-brand-dark: #115e59;
--doc-accent: #16a34a;
--doc-danger: #b91c1c;
--doc-warning: #b45309;
--doc-radius: 22px;
--doc-shadow: 0 24px 70px rgba(15, 35, 31, .12);
}
body.documentation-module {
margin: 0;
background: linear-gradient(135deg, #eef8f3 0%, #f8fafc 45%, #ecfdf5 100%);
color: var(--doc-ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
min-height: 100vh;
}
.doc-shell { max-width: 1240px; margin: 0 auto; padding: 28px 20px 56px; }
.doc-hero {
display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center;
padding: 28px; border-radius: 30px; color: #fff;
background: radial-gradient(circle at top left, rgba(255,255,255,.24), transparent 34%), linear-gradient(135deg, #064e3b, #0f766e 52%, #16a34a);
box-shadow: var(--doc-shadow); margin-bottom: 22px;
}
.doc-eyebrow { text-transform: uppercase; font-size: 12px; letter-spacing: .16em; font-weight: 800; opacity: .82; margin: 0 0 10px; }
.doc-hero h1 { margin: 0; font-size: clamp(30px, 5vw, 52px); line-height: .98; letter-spacing: -.04em; }
.doc-hero p { max-width: 720px; margin: 14px 0 0; color: rgba(255,255,255,.84); font-size: 16px; line-height: 1.65; }
.doc-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.doc-button {
border: 1px solid transparent; border-radius: 999px; padding: 11px 16px; font-weight: 800; font-size: 14px;
text-decoration: none; display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
}
.doc-button.primary { background: #fff; color: var(--doc-brand-dark); }
.doc-button.secondary { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.32); }
.doc-button.dark { background: var(--doc-brand); color: #fff; }
.doc-button.light { background: #f8fafc; color: var(--doc-ink); border-color: var(--doc-line); }
.doc-button.danger { background: #fef2f2; color: var(--doc-danger); border-color: #fecaca; padding: 8px 12px; }
.doc-card { background: rgba(255,255,255,.92); border: 1px solid var(--doc-line); border-radius: var(--doc-radius); box-shadow: 0 14px 45px rgba(15,35,31,.08); overflow: hidden; }
.doc-card-header { padding: 20px 22px; border-bottom: 1px solid var(--doc-line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.doc-card-body { padding: 22px; }
.doc-grid { display: grid; gap: 18px; }
.doc-grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 22px 0; }
.doc-stat { padding: 20px; }
.doc-stat strong { display:block; font-size: 30px; letter-spacing: -.04em; }
.doc-stat span { color: var(--doc-muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.doc-table { width: 100%; border-collapse: collapse; }
.doc-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--doc-muted); padding: 12px; border-bottom: 1px solid var(--doc-line); }
.doc-table td { padding: 14px 12px; border-bottom: 1px solid #edf3f0; vertical-align: top; }
.doc-table a { color: var(--doc-brand-dark); font-weight: 800; text-decoration: none; }
.doc-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 800; background: #ecfdf5; color: #065f46; border: 1px solid #bbf7d0; }
.doc-badge.draft { background: #f8fafc; color: #475569; border-color: #cbd5e1; }
.doc-badge.archived { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.doc-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.doc-field.full { grid-column: 1 / -1; }
.doc-label { display: block; font-weight: 800; margin-bottom: 8px; font-size: 14px; }
.doc-input, .doc-select, .doc-textarea {
width: 100%; box-sizing: border-box; border: 1px solid #cbd5e1; border-radius: 14px; padding: 12px 14px;
background: #fff; color: var(--doc-ink); font: inherit;
}
.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 #cbd5e1; border-radius: 16px; overflow: hidden; background: #fff; }
.doc-editor .doc-textarea { border: 0; border-radius: 0; min-height: 420px; }
.doc-editor-toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; background: #f8fafc; border-bottom: 1px solid var(--doc-line); }
.doc-editor-toolbar button { border: 1px solid #cbd5e1; background: #fff; color: var(--doc-ink); border-radius: 10px; padding: 7px 10px; font-weight: 800; cursor: pointer; }
.doc-editor-toolbar button:hover, .doc-editor-toolbar button:focus { border-color: var(--doc-brand); outline: 2px solid rgba(15, 118, 110, .18); }
.editor-help { padding: 0 14px 12px; margin: -4px 0 0; font-size: 13px; }
.doc-error { color: var(--doc-danger); font-size: 13px; margin-top: 6px; }
.doc-alert { border-radius: 16px; padding: 14px 16px; background: #ecfdf5; color: #065f46; border: 1px solid #bbf7d0; margin-bottom: 18px; font-weight: 700; }
.doc-filter { display: grid; grid-template-columns: 1fr 180px 220px auto; gap: 12px; margin-bottom: 18px; }
.doc-content { line-height: 1.75; font-size: 16px; }
.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: 7px; padding: .14rem .32rem; font-size: .92em; }
.doc-content pre { overflow-x: auto; background: #0f172a; color: #e2e8f0; border-radius: 16px; padding: 16px; }
.doc-content pre code { background: transparent; color: inherit; padding: 0; }
.doc-content blockquote { border-left: 4px solid var(--doc-brand); padding-left: 16px; 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: 10px 12px; text-align: left; }
.doc-muted { color: var(--doc-muted); }
.doc-link { color: var(--doc-brand-dark); font-weight: 800; text-decoration: none; }
.doc-attachment-list { display: grid; gap: 10px; }
.doc-attachment-item { display: flex; justify-content: space-between; align-items: center; gap: 14px; border: 1px solid var(--doc-line); border-radius: 14px; padding: 12px 14px; background: #fff; }
@media (max-width: 860px) {
.doc-hero { grid-template-columns: 1fr; }
.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-shell { padding: 16px 12px 36px; }
.doc-hero { padding: 22px; border-radius: 22px; }
.doc-grid.stats { grid-template-columns: 1fr; }
}
</style>
</head>
<body class="documentation-module">
<main class="doc-shell">
@yield('content')
</main>
<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>
</body>
</html>
@@ -1,43 +0,0 @@
@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 dark" type="submit">Save category</button>
<a class="doc-button light" href="{{ route('documentation.categories.index') }}">Cancel</a>
</div>
@@ -1,109 +0,0 @@
@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&#10;" data-md-after="&#10;```" title="Code block">Code block</button>
<button type="button" data-md-before="| Column | Column |&#10;| --- | --- |&#10;| 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 dark" type="submit">Save document</button>
<a class="doc-button light" href="{{ route('documentation.documents.index') }}">Cancel</a>
</div>
@@ -1,13 +0,0 @@
<section class="doc-hero">
<div>
<p class="doc-eyebrow">{{ $eyebrow ?? 'Documentation Suite' }}</p>
<h1>{{ $title ?? 'Documentation' }}</h1>
<p>{{ $subtitle ?? 'Manage controlled documents, policies, guides, files, and operational knowledge in one professional workspace.' }}</p>
<div class="doc-actions">
<a class="doc-button primary" href="{{ route('documentation.documents.create') }}">Create document</a>
<a class="doc-button secondary" href="{{ route('documentation.categories.index') }}">Manage categories</a>
<a class="doc-button secondary" href="{{ route('documentation.documents.index') }}">Document register</a>
</div>
</div>
<div aria-hidden="true" style="width:140px;height:140px;border-radius:32px;background:rgba(255,255,255,.16);display:grid;place-items:center;border:1px solid rgba(255,255,255,.26);font-size:58px;font-weight:900;">D</div>
</section>
-11
View File
@@ -1,11 +0,0 @@
<?php
use Illuminate\Support\Facades\Route;
Route::prefix('documentation')->name('api.documentation.')->group(function (): void {
Route::get('/status', static fn (): array => [
'module' => 'documentation',
'status' => 'ok',
'version' => '1.1.0',
])->name('status');
});
-24
View File
@@ -1,24 +0,0 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Documentation\Http\Controllers\DocumentationCategoryController;
use Modules\Documentation\Http\Controllers\DocumentationController;
Route::prefix(config('documentation.route_prefix', 'documentation'))
->name('documentation.')
->middleware(config('documentation.middleware', ['web', 'auth']))
->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']);
});
@@ -1,176 +0,0 @@
<?php
namespace Modules\Documentation\Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;
use Modules\Documentation\Models\DocumentationCategory;
use Modules\Documentation\Models\DocumentationDocument;
use Modules\Documentation\Models\DocumentationAttachment;
class DocumentationModuleTest extends TestCase
{
use RefreshDatabase;
/**
* The documentation dashboard renders for authenticated users.
*/
public function test_documentation_dashboard_renders(): void
{
$user = \App\Models\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 = \App\Models\User::factory()->create();
$category = DocumentationCategory::query()->create([
'name' => 'Operations',
'slug' => 'operations',
'colour' => 'emerald',
'is_active' => true,
]);
$response = $this->actingAs($user)->post(route('documentation.documents.store'), [
'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 = \App\Models\User::factory()->create();
$file = UploadedFile::fake()->createWithContent('goods-in.md', "# Goods In\n\n- Scan delivery note\n- Confirm quantities");
$response = $this->actingAs($user)->post(route('documentation.documents.store'), [
'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 = \App\Models\User::factory()->create();
$response = $this->actingAs($user)->post(route('documentation.documents.store'), [
'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)
->delete(route('documentation.documents.attachments.destroy', [$document, $attachment]))
->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 = \App\Models\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 = \App\Models\User::factory()->create();
$this->actingAs($user)->post(route('documentation.categories.store'), [
'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,
]);
}
}
-14
View File
@@ -1,14 +0,0 @@
version: 1.4.0
date: 2026-06-15
changes:
- Added professional documentation dashboard and document CRUD.
- Added document categories with status, ordering, colour, and icon support.
- Added migrations, Eloquent models, form requests, routes, and feature coverage.
- Added self-contained Abbott-style module views with accessible responsive styling.
- Added Markdown upload processing for .md files with safe rendered HTML preview.
- Added Markdown import coverage and styling for headings, code blocks, tables, and blockquotes.
- Added multiple supporting attachments per document with upload, download, removal, storage cleanup, and tests.
- Added a free built-in Markdown editor toolbar with controls for headings, bold, italic, quotes, lists, links, inline code, fenced code blocks, and tables.
- Added WMS Support sidebar integration for Documentation, New Document, and Categories links using the existing sidebar colour scheme and active-state conventions.
- Added a root documentation.index route while preserving documentation.documents.index for CRUD navigation.
- Fixed module composer metadata and synced module.json version.
-27
View File
@@ -1,27 +0,0 @@
{
"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/"
}
}
}
-19
View File
@@ -1,19 +0,0 @@
{
"name": "Documentation",
"alias": "documentation",
"version": "1.4.0",
"description": "Professional document management and knowledge-base module with categories, CRUD, publishing, Markdown editing/import support, code blocks, attachments, and WMS Support navigation integration.",
"keywords": [
"documentation",
"documents",
"knowledge-base",
"crud"
],
"priority": 0,
"providers": [
"Modules\\Documentation\\Providers\\DocumentationServiceProvider"
],
"aliases": {},
"files": [],
"requires": []
}
-25
View File
@@ -1,25 +0,0 @@
<?php
return [
'name' => 'Documentation',
'route_prefix' => 'documentation',
'middleware' => ['web', 'auth'],
'storage_disk' => env('DOCUMENTATION_DISK', 'public'),
'upload_path' => env('DOCUMENTATION_UPLOAD_PATH', 'documentation'),
'allowed_upload_mimes' => [
'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'md', 'csv', 'png', 'jpg', 'jpeg', 'webp',
],
'max_upload_kb' => 20480,
'import_markdown_attachments' => true,
'max_markdown_import_bytes' => 1048576,
'editor' => [
'markdown_toolbar' => true,
'supports_code_blocks' => true,
'supports_tables' => true,
],
'statuses' => [
'draft' => 'Draft',
'published' => 'Published',
'archived' => 'Archived',
],
];
@@ -1,35 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('documentation_categories', function (Blueprint $table): void {
$table->id();
$table->string('name')->comment('Human-readable category name.');
$table->string('slug')->unique()->comment('URL-safe category identifier.');
$table->string('icon')->nullable()->comment('Optional UI icon class or key.');
$table->string('colour', 32)->default('emerald')->comment('Display colour token.');
$table->text('description')->nullable()->comment('Category description shown in the documentation UI.');
$table->unsignedInteger('sort_order')->default(0)->index()->comment('Manual display order.');
$table->boolean('is_active')->default(true)->index()->comment('Whether the category is visible and usable.');
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete()->comment('User that created the category.');
$table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete()->comment('Last user that updated the category.');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('documentation_categories');
}
};
@@ -1,47 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('documentation_documents', function (Blueprint $table): void {
$table->id();
$table->foreignId('documentation_category_id')->nullable()->constrained('documentation_categories')->nullOnDelete()->comment('Optional owning documentation category.');
$table->string('title')->comment('Document title.');
$table->string('slug')->unique()->comment('URL-safe document identifier.');
$table->string('summary', 500)->nullable()->comment('Short document summary.');
$table->longText('body')->nullable()->comment('Full document body, markdown or HTML-safe text depending on editor implementation.');
$table->string('status', 32)->default('draft')->index()->comment('Workflow status: draft, published, or archived.');
$table->boolean('is_featured')->default(false)->index()->comment('Whether this document is highlighted on the documentation dashboard.');
$table->string('version', 50)->default('1.0.0')->comment('Document version label.');
$table->string('reference', 100)->nullable()->index()->comment('Optional business reference or document code.');
$table->string('attachment_disk')->nullable()->comment('Storage disk used for the attached file.');
$table->string('attachment_path')->nullable()->comment('Storage path for the attached file.');
$table->string('attachment_name')->nullable()->comment('Original uploaded file name.');
$table->string('attachment_mime')->nullable()->comment('Uploaded file MIME type.');
$table->unsignedBigInteger('attachment_size')->nullable()->comment('Uploaded file size in bytes.');
$table->timestamp('published_at')->nullable()->index()->comment('Date/time the document was published.');
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete()->comment('User that created the document.');
$table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete()->comment('Last user that updated the document.');
$table->timestamps();
$table->softDeletes();
$table->index(['status', 'is_featured']);
$table->index(['documentation_category_id', 'status']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('documentation_documents');
}
};
@@ -1,35 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('documentation_attachments', function (Blueprint $table): void {
$table->id();
$table->foreignId('documentation_document_id')->constrained('documentation_documents')->cascadeOnDelete()->comment('Owning documentation document.');
$table->string('disk')->comment('Storage disk used for the uploaded attachment.');
$table->string('path')->comment('Storage path for the uploaded attachment.');
$table->string('original_name')->comment('Original uploaded file name.');
$table->string('mime_type')->nullable()->comment('Uploaded file MIME type.');
$table->unsignedBigInteger('size')->nullable()->comment('Uploaded file size in bytes.');
$table->foreignId('uploaded_by')->nullable()->constrained('users')->nullOnDelete()->comment('User that uploaded the attachment.');
$table->timestamps();
$table->index(['documentation_document_id', 'created_at']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('documentation_attachments');
}
};
@@ -1,21 +0,0 @@
<?php
namespace Modules\Documentation\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class DocumentationDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
// $this->call("OthersTableSeeder");
}
}
-12
View File
@@ -1,12 +0,0 @@
<?php
use Modules\Documentation\Support\ModuleInfo;
if (! function_exists('documentation_feature_enabled')) {
/**
* Check if a feature is enabled in the config.
*/
function documentation_feature_enabled(string $key): bool
{
return (bool) config(ModuleInfo::nameLower().".features.{$key}", false);
}
}
@@ -1,155 +0,0 @@
<?php
namespace Modules\Documentation\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Factory;
use Illuminate\Support\Facades\File;
use Modules\Documentation\Support\ModuleInfo;
use Config;
class DocumentationServiceProvider extends ServiceProvider
{
/**
* @var string $moduleName
*/
protected string $moduleName = 'Documentation';
/**
* @var string $moduleNameLower
*/
protected string $moduleNameLower = 'documentation';
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides():array
{
return [];
}
/**
* Boot the application events.
*
* @return void
*/
public function boot() : void
{
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
$this->registerHelpers();
$this->registerCommands();
$this->loadMigrationsFrom(module_path(ModuleInfo::name(), 'Database/Migrations'));
}
/**
* Register the service provider.
*
* @return void
*/
public function register(): void
{
$this->app->register(RouteServiceProvider::class);
}
/**
* Register the helpers.
*
* @return void
*/
protected function registerHelpers(): void
{
foreach (glob(__DIR__.'/../Helpers/*.php') as $filename) {
require_once $filename;
}
}
/**
* Dynamically Register Commands.
*
* @return void
*/
public function registerCommands(): void
{
if (!$this->app->runningInConsole()) {
return;
}
$commandPath = __DIR__ . '/../Console';
$commands = collect(File::allFiles($commandPath))
->map(function ($file) {
$class = 'Modules\\' . $this->moduleName . '\\Console\\' . $file->getFilenameWithoutExtension();
return $class;
})
->filter(function ($class) {
return class_exists($class);
})
->values()
->all();
$this->commands($commands);
}
/**
* Register config.
*
* @return void
*/
protected function registerConfig(): void
{
$this->publishes([
module_path(ModuleInfo::name(), 'Config/config.php') => config_path( ModuleInfo::nameLower(). '.php'),
], 'config');
$this->mergeConfigFrom(
module_path(ModuleInfo::name(), 'Config/config.php'), ModuleInfo::nameLower()
);
}
/**
* Register views.
*
* @return void
*/
public function registerViews(): void
{
$viewPath = resource_path('views/modules/' . ModuleInfo::nameLower());
$sourcePath = module_path(ModuleInfo::name(), 'Resources/views');
$this->publishes([
$sourcePath => $viewPath
], ['views', ModuleInfo::nameLower() . '-module-views']);
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), ModuleInfo::nameLower());
}
/**
* Register translations.
*
* @return void
*/
public function registerTranslations(): void
{
$langPath = resource_path('lang/modules/' . ModuleInfo::nameLower());
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, ModuleInfo::nameLower());
} else {
$this->loadTranslationsFrom(module_path(ModuleInfo::name(), 'Resources/lang'), ModuleInfo::nameLower());
}
}
/**
* Regsiter View Paths
* @return array
*/
private function getPublishableViewPaths(): array
{
$paths = [];
foreach (Config::get('view.paths') as $path) {
if (is_dir($path . '/modules/' . ModuleInfo::nameLower())) {
$paths[] = $path . '/modules/' . ModuleInfo::nameLower();
}
}
return $paths;
}
}
@@ -3,6 +3,7 @@
@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.',
@@ -15,4 +16,5 @@
</form>
</div>
</section>
</div>
@endsection
@@ -3,6 +3,7 @@
@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.',
@@ -15,4 +16,5 @@
</form>
</div>
</section>
</div>
@endsection
@@ -3,6 +3,7 @@
@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.',
@@ -54,4 +55,5 @@
<div style="margin-top:18px;">{{ $categories->links() }}</div>
</div>
</section>
</div>
@endsection
@@ -3,6 +3,7 @@
@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.',
@@ -15,4 +16,5 @@
</form>
</div>
</section>
</div>
@endsection
@@ -3,6 +3,7 @@
@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.',
@@ -22,4 +23,5 @@
@method('DELETE')
</form>
@endforeach
</div>
@endsection
@@ -3,6 +3,7 @@
@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.',
@@ -89,4 +90,5 @@
<div style="margin-top:18px;">{{ $documents->links() }}</div>
</div>
</section>
</div>
@endsection
@@ -3,6 +3,7 @@
@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.',
@@ -50,4 +51,5 @@
</div>
</section>
@endif
</div>
@endsection
@@ -6,104 +6,536 @@
<title>{{ trim($__env->yieldContent('title', 'Documentation')) }} - {{ config('app.name', 'Laravel') }}</title>
<style>
:root {
--doc-ink: #10231f;
--doc-muted: #64748b;
--doc-line: #dbe7e2;
--doc-ink: #18181b;
--doc-muted: #71717a;
--doc-line: #e4e4e7;
--doc-panel: #ffffff;
--doc-soft: #f5faf8;
--doc-brand: #0f766e;
--doc-brand-dark: #115e59;
--doc-accent: #16a34a;
--doc-danger: #b91c1c;
--doc-warning: #b45309;
--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 24px 70px rgba(15, 35, 31, .12);
--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: linear-gradient(135deg, #eef8f3 0%, #f8fafc 45%, #ecfdf5 100%);
background: #ffffff;
color: var(--doc-ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
min-height: 100vh;
}
.doc-shell { max-width: 1240px; margin: 0 auto; padding: 28px 20px 56px; }
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: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center;
padding: 28px; border-radius: 30px; color: #fff;
background: radial-gradient(circle at top left, rgba(255,255,255,.24), transparent 34%), linear-gradient(135deg, #064e3b, #0f766e 52%, #16a34a);
box-shadow: var(--doc-shadow); margin-bottom: 22px;
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-eyebrow { text-transform: uppercase; font-size: 12px; letter-spacing: .16em; font-weight: 800; opacity: .82; margin: 0 0 10px; }
.doc-hero h1 { margin: 0; font-size: clamp(30px, 5vw, 52px); line-height: .98; letter-spacing: -.04em; }
.doc-hero p { max-width: 720px; margin: 14px 0 0; color: rgba(255,255,255,.84); font-size: 16px; line-height: 1.65; }
.doc-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.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: 999px; padding: 11px 16px; font-weight: 800; font-size: 14px;
text-decoration: none; display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
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.primary { background: #fff; color: var(--doc-brand-dark); }
.doc-button.secondary { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.32); }
.doc-button.dark { background: var(--doc-brand); color: #fff; }
.doc-button.light { background: #f8fafc; color: var(--doc-ink); border-color: var(--doc-line); }
.doc-button.danger { background: #fef2f2; color: var(--doc-danger); border-color: #fecaca; padding: 8px 12px; }
.doc-card { background: rgba(255,255,255,.92); border: 1px solid var(--doc-line); border-radius: var(--doc-radius); box-shadow: 0 14px 45px rgba(15,35,31,.08); overflow: hidden; }
.doc-card-header { padding: 20px 22px; border-bottom: 1px solid var(--doc-line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.doc-card-body { padding: 22px; }
.doc-grid { display: grid; gap: 18px; }
.doc-grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 22px 0; }
.doc-stat { padding: 20px; }
.doc-stat strong { display:block; font-size: 30px; letter-spacing: -.04em; }
.doc-stat span { color: var(--doc-muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.doc-table { width: 100%; border-collapse: collapse; }
.doc-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--doc-muted); padding: 12px; border-bottom: 1px solid var(--doc-line); }
.doc-table td { padding: 14px 12px; border-bottom: 1px solid #edf3f0; vertical-align: top; }
.doc-table a { color: var(--doc-brand-dark); font-weight: 800; text-decoration: none; }
.doc-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 800; background: #ecfdf5; color: #065f46; border: 1px solid #bbf7d0; }
.doc-badge.draft { background: #f8fafc; color: #475569; border-color: #cbd5e1; }
.doc-badge.archived { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.doc-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.doc-field.full { grid-column: 1 / -1; }
.doc-label { display: block; font-weight: 800; margin-bottom: 8px; font-size: 14px; }
.doc-input, .doc-select, .doc-textarea {
width: 100%; box-sizing: border-box; border: 1px solid #cbd5e1; border-radius: 14px; padding: 12px 14px;
background: #fff; color: var(--doc-ink); font: inherit;
.doc-button:hover {
transform: translateY(-1px);
}
.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 #cbd5e1; border-radius: 16px; overflow: hidden; background: #fff; }
.doc-editor .doc-textarea { border: 0; border-radius: 0; min-height: 420px; }
.doc-editor-toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; background: #f8fafc; border-bottom: 1px solid var(--doc-line); }
.doc-editor-toolbar button { border: 1px solid #cbd5e1; background: #fff; color: var(--doc-ink); border-radius: 10px; padding: 7px 10px; font-weight: 800; cursor: pointer; }
.doc-editor-toolbar button:hover, .doc-editor-toolbar button:focus { border-color: var(--doc-brand); outline: 2px solid rgba(15, 118, 110, .18); }
.editor-help { padding: 0 14px 12px; margin: -4px 0 0; font-size: 13px; }
.doc-error { color: var(--doc-danger); font-size: 13px; margin-top: 6px; }
.doc-alert { border-radius: 16px; padding: 14px 16px; background: #ecfdf5; color: #065f46; border: 1px solid #bbf7d0; margin-bottom: 18px; font-weight: 700; }
.doc-filter { display: grid; grid-template-columns: 1fr 180px 220px auto; gap: 12px; margin-bottom: 18px; }
.doc-content { line-height: 1.75; font-size: 16px; }
.doc-content h1, .doc-content h2, .doc-content h3 { line-height: 1.2; letter-spacing: -.025em; margin: 1.4em 0 .55em; }
.doc-button.primary,
.doc-button.dark {
background: #2563eb;
color: #ffffff;
border-color: #2563eb;
}
.doc-button.primary:hover,
.doc-button.dark:hover {
background: #1d4ed8;
border-color: #1d4ed8;
}
.doc-button.secondary {
background: rgba(255, 255, 255, .10);
color: #ffffff;
border-color: rgba(255, 255, 255, .22);
}
.doc-button.secondary:hover {
background: rgba(255, 255, 255, .16);
}
.doc-button.light {
background: #f8fafc;
color: #18181b;
border-color: #d4d4d8;
}
html.dark .doc-button.light {
background: #09090b;
color: #f4f4f5;
border-color: #3f3f46;
}
.doc-button.success {
background: #059669;
color: #ffffff;
border-color: #059669;
}
.doc-button.danger {
background: #dc2626;
color: #ffffff;
border-color: #dc2626;
}
.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: 7px; padding: .14rem .32rem; font-size: .92em; }
.doc-content pre { overflow-x: auto; background: #0f172a; color: #e2e8f0; border-radius: 16px; padding: 16px; }
.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 var(--doc-brand); padding-left: 16px; color: var(--doc-muted); }
.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: 10px 12px; text-align: left; }
.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-link { color: var(--doc-brand-dark); font-weight: 800; text-decoration: none; }
.doc-attachment-list { display: grid; gap: 10px; }
.doc-attachment-item { display: flex; justify-content: space-between; align-items: center; gap: 14px; border: 1px solid var(--doc-line); border-radius: 14px; padding: 12px 14px; background: #fff; }
.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-hero { grid-template-columns: 1fr; }
.doc-grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.doc-filter, .doc-form-grid { grid-template-columns: 1fr; }
.doc-filter,
.doc-form-grid { grid-template-columns: 1fr; }
.doc-table { display: block; overflow-x: auto; }
}
@media (max-width: 560px) {
.doc-shell { padding: 16px 12px 36px; }
.doc-hero { padding: 22px; border-radius: 22px; }
.doc-grid.stats { grid-template-columns: 1fr; }
.doc-hero { padding: 1.375rem; border-radius: 1.375rem; }
}
</style>
</head>
@@ -1,13 +1,17 @@
<section class="doc-hero">
<div>
<p class="doc-eyebrow">{{ $eyebrow ?? 'Documentation Suite' }}</p>
<h1>{{ $title ?? 'Documentation' }}</h1>
<p>{{ $subtitle ?? 'Manage controlled documents, policies, guides, files, and operational knowledge in one professional workspace.' }}</p>
<div class="doc-actions">
<a class="doc-button primary" href="{{ route('documentation.documents.create') }}">Create document</a>
<a class="doc-button secondary" href="{{ route('documentation.categories.index') }}">Manage categories</a>
<a class="doc-button secondary" href="{{ route('documentation.documents.index') }}">Document register</a>
<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 primary" href="{{ route('documentation.documents.create') }}" wire:navigate>Create document</a>
<a class="doc-button secondary" href="{{ route('documentation.categories.index') }}" wire:navigate>Manage categories</a>
<a class="doc-button secondary" href="{{ route('documentation.documents.index') }}" wire:navigate>Document register</a>
</div>
</div>
</div>
<div aria-hidden="true" style="width:140px;height:140px;border-radius:32px;background:rgba(255,255,255,.16);display:grid;place-items:center;border:1px solid rgba(255,255,255,.26);font-size:58px;font-weight:900;">D</div>
</section>
-11
View File
@@ -1,11 +0,0 @@
<?php
use Illuminate\Support\Facades\Route;
Route::prefix('documentation')->name('api.documentation.')->group(function (): void {
Route::get('/status', static fn (): array => [
'module' => 'documentation',
'status' => 'ok',
'version' => '1.1.0',
])->name('status');
});
-23
View File
@@ -1,23 +0,0 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Documentation\Http\Controllers\DocumentationCategoryController;
use Modules\Documentation\Http\Controllers\DocumentationController;
Route::prefix(config('documentation.route_prefix', 'documentation'))
->name('documentation.')
->middleware(config('documentation.middleware', ['web', 'auth']))
->group(function (): void {
Route::get('/', [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']);
});
@@ -1,26 +0,0 @@
<?php
namespace Modules\Documentation\Support;
class ModuleInfo
{
protected static string $moduleName = 'Documentation';
/**
* defines the Module Name
* @return string
*/
public static function name(): string
{
return static::$moduleName;
}
/**
* define the lowercase version
* @return string
*/
public static function nameLower(): string
{
return strtolower(static::$moduleName);
}
}
View File
+16 -2
View File
@@ -1,5 +1,11 @@
version: 1.3.0
date: 2026-06-13
- version: 1.5.0
date: 2026-06-15
changes:
- Updated the Documentation module visual theme to match the WMS/Helpdesk slate-blue shell, zinc cards, dark-mode surfaces, blue primary actions, emerald success states, red danger states, and amber warnings.
- Reworked the Documentation hero to use the same professional gradient/header pattern as the Helpdesk workflow screens.
version: 1.4.0
date: 2026-06-15
changes:
- Added professional documentation dashboard and document CRUD.
- Added document categories with status, ordering, colour, and icon support.
@@ -9,4 +15,12 @@ changes:
- Added Markdown import coverage and styling for headings, code blocks, tables, and blockquotes.
- Added multiple supporting attachments per document with upload, download, removal, storage cleanup, and tests.
- Added a free built-in Markdown editor toolbar with controls for headings, bold, italic, quotes, lists, links, inline code, fenced code blocks, and tables.
- Added WMS Support sidebar integration for Documentation, New Document, and Categories links using the existing sidebar colour scheme and active-state conventions.
- Added a root documentation.index route while preserving documentation.documents.index for CRUD navigation.
- Fixed module composer metadata and synced module.json version.
- version: 1.4.1
date: 2026-06-15
changes:
- Fixed sidebar integration so Documentation is rendered directly under the existing Support menu when Documentation routes exist.
- Added direct replacement Blade block for the current WMS app shell.
+2 -2
View File
@@ -1,8 +1,8 @@
{
"name": "Documentation",
"alias": "documentation",
"version": "1.3.0",
"description": "Professional document management and knowledge-base module with categories, CRUD, publishing, Markdown editing/import support, code blocks, and attachments.",
"version": "1.5.0",
"description": "Professional document management and knowledge-base module with categories, CRUD, publishing, Markdown editing/import support, code blocks, attachments, and WMS Support navigation integration.",
"keywords": [
"documentation",
"documents",
-17
View File
@@ -1,17 +0,0 @@
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"cross-env": "^7.0",
"laravel-mix": "^5.0.1",
"laravel-mix-merge-manifest": "^0.1.2"
}
}
-11
View File
@@ -1,11 +0,0 @@
const dotenvExpand = require('dotenv-expand');
dotenvExpand(require('dotenv').config({ path: '../../.env'/*, debug: true*/}));
const mix = require('laravel-mix');
mix.js(__dirname + '/Resources/assets/js/app.js', 'js/documentation.js')
.sass( __dirname + '/Resources/assets/sass/app.scss', 'css/documentation.css');
if (mix.inProduction()) {
mix.version();
}
@@ -1,9 +1,11 @@
# WMS support navigation integration
# Sidebar support menu replacement
Replace the existing `{{-- Support Portal --}} ... {{-- Support Portal end --}}` block in the application shell with:
Replace the existing `{{-- Support Portal --}} ... {{-- Support Portal end --}}` block in your app shell with this direct block:
```blade
@include('partials.wms-support-navigation')
```
The partial keeps the existing WMS sidebar classes, FontAwesome icon pattern, `wire:navigate`, mobile-close behaviour, and active-state conventions.
Or paste the contents of `resources/views/partials/wms-support-navigation-direct-replacement.blade.php` directly into the sidebar.
This fixes Documentation not appearing because the Support group now renders when either Helpdesk routes or Documentation routes exist.
@@ -1,7 +1,7 @@
{{-- Support Portal + Documentation --}}
{{-- Support Portal --}}
@php
$helpdeskEnabled = Route::has('helpdesk.index') || Route::has('helpdesk.tickets.index');
$documentationEnabled = Route::has('documentation.documents.index') || Route::has('documentation.categories.index');
$documentationEnabled = Route::has('documentation.index') || Route::has('documentation.documents.index');
$helpdeskSettingsRoute = Route::has('helpdesk.settings')
? 'helpdesk.settings'
@@ -18,6 +18,18 @@
$helpdeskWorkflowRoute = Route::has('helpdesk.workflow-templates.index')
? 'helpdesk.workflow-templates.index'
: null;
$documentationDashboardRoute = Route::has('documentation.index')
? 'documentation.index'
: (Route::has('documentation.documents.index') ? 'documentation.documents.index' : null);
$documentationCreateRoute = Route::has('documentation.documents.create')
? 'documentation.documents.create'
: null;
$documentationCategoriesRoute = Route::has('documentation.categories.index')
? 'documentation.categories.index'
: null;
@endphp
@if($helpdeskEnabled || $documentationEnabled)
@@ -52,27 +64,6 @@
</a>
@endif
@if($documentationEnabled)
<a href="{{ route('documentation.documents.index') }}" wire:navigate class="wms-sidebar-link @if(request()->routeIs('documentation.documents.*')) is-active @endif" title="{{ __('Documentation') }}">
<i class="fa-solid fa-book-open-reader wms-sidebar-icon" aria-hidden="true"></i>
<span data-wms-sidebar-label>{{ __('Documentation') }}</span>
</a>
@endif
@if(Route::has('documentation.documents.create'))
<a href="{{ route('documentation.documents.create') }}" wire:navigate class="wms-sidebar-link @if(request()->routeIs('documentation.documents.create')) is-active @endif" title="{{ __('New Document') }}">
<i class="fa-solid fa-file-circle-plus wms-sidebar-icon" aria-hidden="true"></i>
<span data-wms-sidebar-label>{{ __('New Document') }}</span>
</a>
@endif
@if(Route::has('documentation.categories.index'))
<a href="{{ route('documentation.categories.index') }}" wire:navigate class="wms-sidebar-link @if(request()->routeIs('documentation.categories.*')) is-active @endif" title="{{ __('Document Categories') }}">
<i class="fa-solid fa-folder-tree wms-sidebar-icon" aria-hidden="true"></i>
<span data-wms-sidebar-label>{{ __('Categories') }}</span>
</a>
@endif
@if($helpdeskGitRoute)
<a href="{{ route($helpdeskGitRoute) }}" wire:navigate class="wms-sidebar-link @if(request()->routeIs('helpdesk.git.*')) is-active @endif" title="{{ __('Git Tracking') }}">
<i class="fa-solid fa-code-commit wms-sidebar-icon" aria-hidden="true"></i>
@@ -93,6 +84,27 @@
<span data-wms-sidebar-label>{{ __('Settings') }}</span>
</a>
@endif
@if($documentationDashboardRoute)
<a href="{{ route($documentationDashboardRoute) }}" wire:navigate class="wms-sidebar-link @if(request()->routeIs('documentation.index') || request()->routeIs('documentation.documents.*')) is-active @endif" title="{{ __('Documentation') }}">
<i class="fa-solid fa-book-open wms-sidebar-icon" aria-hidden="true"></i>
<span data-wms-sidebar-label>{{ __('Documentation') }}</span>
</a>
@endif
@if($documentationCreateRoute)
<a href="{{ route($documentationCreateRoute) }}" wire:navigate class="wms-sidebar-link @if(request()->routeIs('documentation.documents.create')) is-active @endif" title="{{ __('New Document') }}">
<i class="fa-solid fa-file-circle-plus wms-sidebar-icon" aria-hidden="true"></i>
<span data-wms-sidebar-label>{{ __('New Document') }}</span>
</a>
@endif
@if($documentationCategoriesRoute)
<a href="{{ route($documentationCategoriesRoute) }}" wire:navigate class="wms-sidebar-link @if(request()->routeIs('documentation.categories.*')) is-active @endif" title="{{ __('Document Categories') }}">
<i class="fa-solid fa-folder-tree wms-sidebar-icon" aria-hidden="true"></i>
<span data-wms-sidebar-label>{{ __('Categories') }}</span>
</a>
@endif
</div>
@endif
{{-- Support Portal + Documentation end --}}
{{-- Support Portal end --}}