diff --git a/CLAUDE.md b/CLAUDE.md
index 3012c18..182d249 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
## Project Overview
-Taiwan NPO (Non-Profit Organization) management platform built with Laravel 11. Features member lifecycle management, multi-tier financial approval workflows, issue tracking, and document management with version control.
+Taiwan NPO (Non-Profit Organization) management platform built with Laravel 10 (PHP 8.1+). Features member lifecycle management, multi-tier financial approval workflows, issue tracking, and document management. UI is in Traditional Chinese. Currency is TWD (NT$).
## Commands
@@ -28,21 +28,40 @@ php artisan db:seed --class=FinancialWorkflowTestDataSeeder # Finance test data
./vendor/bin/phpstan analyse # Static analysis
```
+## Tech Stack
+
+- **Backend**: Laravel 10, PHP 8.1+, Spatie Laravel Permission
+- **Frontend**: Blade templates, Tailwind CSS 3.1 (`darkMode: 'class'`), Alpine.js 3.4, Vite 5
+- **PDF/Excel**: barryvdh/laravel-dompdf, maatwebsite/excel
+- **QR Codes**: simplesoftwareio/simple-qrcode
+- **DB**: SQLite (dev), MySQL (production)
+
## Architecture
+### Route Structure
+
+Routes split across `routes/web.php` and `routes/auth.php`. Admin routes use group pattern:
+```php
+Route::middleware(['auth', 'admin'])->prefix('admin')->name('admin.')->group(...)
+```
+- **Public**: `/register/member`, `/documents`
+- **Member** (auth only): dashboard, payment submission
+- **Admin** (auth + admin): `/admin/*` with `admin.{module}.{action}` named routes
+
+The `admin` middleware (`EnsureUserIsAdmin`) allows access if user has `admin` role OR any permissions at all.
+
### Multi-Tier Approval Workflows
-The system uses tiered approval based on amount thresholds (configurable):
+Tiered approval based on amount thresholds (configurable in `config/accounting.php`):
- **Small (<5,000)**: Secretary approval only
- **Medium (5,000-50,000)**: Secretary → Chair
- **Large (>50,000)**: Secretary → Chair → Board
-Finance documents follow a 3-stage lifecycle:
-1. **Approval Stage**: Multi-tier approval based on amount
-2. **Disbursement Stage**: Dual confirmation (requester + cashier)
-3. **Recording Stage**: Accountant records to ledger
+Finance documents follow a 3-stage lifecycle with separate status fields:
+1. **Approval Stage** (`status`): Multi-tier approval based on amount
+2. **Disbursement Stage** (`disbursement_status`): Dual confirmation (requester + cashier)
+3. **Recording Stage** (`recording_status`): Accountant records to ledger
-Key model methods for workflow state:
```php
$doc->isApprovalComplete() // All required approvals obtained
$doc->isDisbursementComplete() // Both parties confirmed
@@ -50,40 +69,61 @@ $doc->isRecordingComplete() // Ledger entry created
$doc->isFullyProcessed() // All 3 stages complete
```
-### RBAC Structure
+### Shared Traits
-Uses Spatie Laravel Permission. Core financial roles:
-- `finance_requester`: Submit finance documents
-- `finance_cashier`: Tier 1 approval, payment execution
-- `finance_accountant`: Tier 2 approval, create payment orders
-- `finance_chair`: Tier 3 approval
-- `finance_board_member`: Large amount approval
-
-Permission checks: `$user->can('permission-name')` or `@can('permission-name')` in Blade.
+- **`HasApprovalWorkflow`**: Multi-tier approval with self-approval prevention (`isSelfApproval()`)
+- **`HasAccountingEntries`**: Double-entry bookkeeping, auto-generation, balance validation
### Service Layer
-Complex business logic lives in `app/Services/`:
-- `MembershipFeeCalculator`: Calculates fees with disability discount support
+Complex business logic in `app/Services/`:
+- `MembershipFeeCalculator`: Fees with disability discount support
- `SettingsService`: System-wide settings with caching
+- `FinanceDocumentApprovalService`: Multi-tier approval orchestration
+- `PaymentVerificationService`: Payment workflow coordination
+
+Global helper: `settings('key')` returns cached setting values (defined in `app/helpers.php`, autoloaded).
+
+### RBAC Structure
+
+Uses Spatie Laravel Permission. Core financial roles:
+- `finance_requester`, `finance_cashier`, `finance_accountant`, `finance_chair`, `finance_board_member`
+
+Permission checks: `$user->can('permission-name')` or `@can('permission-name')` in Blade.
### Data Security Patterns
-- **National ID**: AES-256 encrypted (`national_id_encrypted`), SHA256 hashed for search (`national_id_hash`)
-- **File uploads**: Private disk storage, served via authenticated controller methods
-- **Audit logging**: All significant actions logged to `audit_logs` table
+- **National ID**: AES-256 encrypted (`national_id_encrypted`), SHA256 hashed for search (`national_id_hash`), virtual accessor `national_id` decrypts on read
+- **File uploads**: Private disk storage, served via authenticated controller
+- **Audit logging**: `AuditLogger::log($action, $auditable, $metadata)` — static class, call in controllers
### Member Lifecycle
States: `pending` → `active` → `expired` / `suspended`
-Key model methods:
+Identity types: `patient`, `parent`, `social`, `other` (病友/家長分類). Members can have `guardian_member_id` for parent-child relationships.
+
```php
$member->hasPaidMembership() // Active with future expiry
$member->canSubmitPayment() // Pending with no pending payment
$member->getNextFeeType() // entrance_fee or annual_fee
```
+### Conventions
+
+- **Status values**: Defined as class constants (e.g., `FinanceDocument::STATUS_PENDING`), not enums or magic strings
+- **Controller validation**: Uses Form Request classes (`StoreMemberRequest`, etc.)
+- **DB transactions**: Used in controllers for multi-step operations
+- **UI text**: Hardcoded Traditional Chinese strings (no `__()` translation layer)
+- **Dark mode**: Supported throughout — use `dark:` Tailwind prefix for styles
+
+### Custom Artisan Commands
+
+- `assign:role` — Manual role assignment
+- `import:members` / `import:accounting-data` / `import:documents` — Bulk imports
+- `send:membership-expiry-reminders` — Automated email notifications
+- `archive:expired-documents` — Document lifecycle cleanup
+
### Testing Patterns
Tests use `RefreshDatabase` trait. Setup commonly includes:
@@ -104,8 +144,12 @@ Test accounts (password: `password`):
## Key Files
-- `routes/web.php` - All web routes (admin routes under `/admin` prefix)
-- `app/Models/FinanceDocument.php` - Core financial workflow logic with status constants
-- `app/Models/Member.php` - Member lifecycle with encrypted field handling
-- `database/seeders/` - RoleSeeder, ChartOfAccountSeeder, TestDataSeeder
-- `docs/SYSTEM_SPECIFICATION.md` - Complete system specification
+- `routes/web.php` — All web routes (admin routes under `/admin` prefix)
+- `config/accounting.php` — Account codes, amount tier thresholds, currency settings
+- `app/Models/FinanceDocument.php` — Core financial workflow logic with 27+ status constants
+- `app/Models/Member.php` — Member lifecycle with encrypted field handling
+- `app/Traits/HasApprovalWorkflow.php` — Shared multi-tier approval behavior
+- `app/Traits/HasAccountingEntries.php` — Double-entry bookkeeping behavior
+- `app/helpers.php` — Global `settings()` helper (autoloaded via composer)
+- `database/seeders/` — RoleSeeder, ChartOfAccountSeeder, TestDataSeeder
+- `docs/SYSTEM_SPECIFICATION.md` — Complete system specification
diff --git a/app/Console/Commands/ImportHugoContent.php b/app/Console/Commands/ImportHugoContent.php
new file mode 100644
index 0000000..569110d
--- /dev/null
+++ b/app/Console/Commands/ImportHugoContent.php
@@ -0,0 +1,527 @@
+option('path') ?: base_path('../usher-site/content/zh');
+ $imagesPath = $this->option('images') ?: base_path('../usher-site/static/images');
+
+ // Expand tilde
+ $contentPath = str_replace('~', getenv('HOME'), $contentPath);
+ $imagesPath = str_replace('~', getenv('HOME'), $imagesPath);
+
+ if (! is_dir($contentPath)) {
+ $this->error("Content directory not found: {$contentPath}");
+
+ return self::FAILURE;
+ }
+
+ $isDryRun = $this->option('dry-run');
+ if ($isDryRun) {
+ $this->warn('DRY RUN — no changes will be written to database.');
+ }
+
+ $this->info("Importing Hugo content from: {$contentPath}");
+ $this->newLine();
+
+ // Get or create a system user for attribution
+ $systemUser = User::where('email', 'admin@test.com')->first()
+ ?? User::first();
+
+ if (! $systemUser) {
+ $this->error('No user found to attribute content to. Please create a user first.');
+
+ return self::FAILURE;
+ }
+
+ $this->info("Attributing content to: {$systemUser->name} ({$systemUser->email})");
+ $this->newLine();
+
+ DB::beginTransaction();
+
+ try {
+ // Import articles by content type
+ $contentTypes = [
+ 'blog' => Article::CONTENT_TYPE_BLOG,
+ 'notice' => Article::CONTENT_TYPE_NOTICE,
+ 'document' => Article::CONTENT_TYPE_DOCUMENT,
+ 'related_news' => Article::CONTENT_TYPE_RELATED_NEWS,
+ ];
+
+ foreach ($contentTypes as $dir => $contentType) {
+ $dirPath = "{$contentPath}/{$dir}";
+ if (is_dir($dirPath)) {
+ $this->importArticles($dirPath, $contentType, $systemUser, $isDryRun);
+ } else {
+ $this->warn("Directory not found, skipping: {$dir}/");
+ }
+ }
+
+ // Import static pages
+ $pageDirectories = [
+ 'about' => '關於我們',
+ 'message' => '理事長的話',
+ 'structure' => '組織架構',
+ 'mission' => '協會任務',
+ 'contact' => '聯繫我們',
+ 'logo_represent' => 'Logo象徵',
+ ];
+
+ foreach ($pageDirectories as $dir => $fallbackTitle) {
+ $dirPath = "{$contentPath}/{$dir}";
+ if (is_dir($dirPath)) {
+ $this->importPage($dirPath, $dir, $fallbackTitle, $systemUser, $isDryRun);
+ } else {
+ $this->warn("Page directory not found, skipping: {$dir}/");
+ }
+ }
+
+ // Copy images
+ if (is_dir($imagesPath)) {
+ $this->copyImages($imagesPath, $isDryRun);
+ } else {
+ $this->warn("Images directory not found: {$imagesPath}");
+ }
+
+ if ($isDryRun) {
+ DB::rollBack();
+ $this->newLine();
+ $this->warn('DRY RUN complete — no changes were made.');
+ } else {
+ DB::commit();
+ }
+ } catch (\Exception $e) {
+ DB::rollBack();
+ $this->error("Import failed: {$e->getMessage()}");
+ $this->error($e->getTraceAsString());
+
+ return self::FAILURE;
+ }
+
+ $this->newLine();
+ $this->info('=== Import Summary ===');
+ $this->table(
+ ['Item', 'Count'],
+ [
+ ['Articles created', $this->articlesCreated],
+ ['Pages created', $this->pagesCreated],
+ ['Categories created', $this->categoriesCreated],
+ ['Tags created', $this->tagsCreated],
+ ['Images copied', $this->imagescopied],
+ ['Skipped (_index.md etc.)', $this->skipped],
+ ]
+ );
+
+ return self::SUCCESS;
+ }
+
+ private function importArticles(string $dirPath, string $contentType, User $user, bool $isDryRun): void
+ {
+ $this->info("Importing {$contentType} articles from: {$dirPath}");
+
+ $files = File::glob("{$dirPath}/*.md");
+
+ foreach ($files as $filePath) {
+ $filename = basename($filePath);
+
+ // Skip _index.md files (Hugo section pages, not content)
+ if ($filename === '_index.md') {
+ $this->skipped++;
+
+ continue;
+ }
+
+ $parsed = $this->parseMarkdownFile($filePath);
+ if (! $parsed) {
+ $this->warn(" Could not parse: {$filename}");
+ $this->skipped++;
+
+ continue;
+ }
+
+ $frontmatter = $parsed['frontmatter'];
+ $body = $parsed['body'];
+
+ // Skip drafts
+ if (! empty($frontmatter['draft']) && $frontmatter['draft'] === true) {
+ $this->line(" Skipping draft: {$filename}");
+ $this->skipped++;
+
+ continue;
+ }
+
+ $title = $frontmatter['title'] ?? pathinfo($filename, PATHINFO_FILENAME);
+
+ // Prefer filename-based slug (Hugo filenames are usually descriptive ASCII)
+ $filenameBase = pathinfo($filename, PATHINFO_FILENAME);
+ $slug = Str::slug($filenameBase);
+ if (empty($slug)) {
+ $slug = Str::slug($title);
+ }
+ if (empty($slug)) {
+ // For Chinese-only titles/filenames, use content_type + short hash
+ $slug = $contentType.'-'.substr(md5($title), 0, 8);
+ }
+
+ // Ensure unique slug
+ $originalSlug = $slug;
+ $counter = 1;
+ while (! $isDryRun && Article::withTrashed()->where('slug', $slug)->exists()) {
+ $slug = "{$originalSlug}-{$counter}";
+ $counter++;
+ }
+
+ $publishedAt = $this->parseDate($frontmatter['date'] ?? null);
+ $description = $frontmatter['description'] ?? null;
+ $summary = $frontmatter['summary'] ?? null;
+ $author = $frontmatter['author'] ?? null;
+ $image = $this->resolveImagePath($frontmatter['image'] ?? null);
+
+ $this->line(" [{$contentType}] {$title} → {$slug}");
+
+ if (! $isDryRun) {
+ $article = Article::create([
+ 'title' => $title,
+ 'slug' => $slug,
+ 'summary' => $summary,
+ 'content' => $body,
+ 'content_type' => $contentType,
+ 'status' => Article::STATUS_PUBLISHED,
+ 'access_level' => Article::ACCESS_LEVEL_PUBLIC,
+ 'featured_image_path' => $image,
+ 'author_name' => $author,
+ 'meta_description' => $description ?: null,
+ 'published_at' => $publishedAt ?? now(),
+ 'created_by_user_id' => $user->id,
+ 'view_count' => 0,
+ ]);
+
+ // Sync categories
+ $categoryNames = $this->extractList($frontmatter, 'categories', 'category');
+ foreach ($categoryNames as $catName) {
+ $category = $this->findOrCreateCategory($catName);
+ $article->categories()->attach($category->id);
+ }
+
+ // Sync tags
+ $tagNames = $this->extractList($frontmatter, 'tags');
+ foreach ($tagNames as $tagName) {
+ $tag = $this->findOrCreateTag($tagName);
+ $article->tags()->attach($tag->id);
+ }
+ }
+
+ $this->articlesCreated++;
+ }
+ }
+
+ private function importPage(string $dirPath, string $slug, string $fallbackTitle, User $user, bool $isDryRun): void
+ {
+ $indexFile = "{$dirPath}/_index.md";
+
+ if (! file_exists($indexFile)) {
+ $this->warn(" No _index.md in {$slug}/, skipping.");
+ $this->skipped++;
+
+ return;
+ }
+
+ $parsed = $this->parseMarkdownFile($indexFile);
+ if (! $parsed) {
+ $this->warn(" Could not parse: {$slug}/_index.md");
+ $this->skipped++;
+
+ return;
+ }
+
+ $frontmatter = $parsed['frontmatter'];
+ $body = $parsed['body'];
+
+ $title = $frontmatter['title'] ?? $fallbackTitle;
+ $description = $frontmatter['description'] ?? null;
+
+ $this->info(" [page] {$title} → {$slug}");
+
+ $parentPage = null;
+
+ if (! $isDryRun) {
+ // Check for existing page with same slug
+ if (Page::withTrashed()->where('slug', $slug)->exists()) {
+ $this->warn(" Page with slug '{$slug}' already exists, skipping.");
+ $this->skipped++;
+
+ return;
+ }
+
+ $parentPage = Page::create([
+ 'title' => $title,
+ 'slug' => $slug,
+ 'content' => $body,
+ 'status' => Page::STATUS_PUBLISHED,
+ 'meta_description' => $description ?: null,
+ 'published_at' => now(),
+ 'created_by_user_id' => $user->id,
+ 'sort_order' => 0,
+ ]);
+ }
+
+ $this->pagesCreated++;
+
+ // Import child pages (non-_index.md files in the same directory)
+ $childFiles = File::glob("{$dirPath}/*.md");
+ $sortOrder = 1;
+
+ foreach ($childFiles as $childFile) {
+ $childFilename = basename($childFile);
+ if ($childFilename === '_index.md') {
+ continue;
+ }
+
+ $childParsed = $this->parseMarkdownFile($childFile);
+ if (! $childParsed) {
+ $this->skipped++;
+
+ continue;
+ }
+
+ $childFm = $childParsed['frontmatter'];
+ $childBody = $childParsed['body'];
+ $childTitle = $childFm['title'] ?? pathinfo($childFilename, PATHINFO_FILENAME);
+ $childSlug = Str::slug(pathinfo($childFilename, PATHINFO_FILENAME));
+ if (empty($childSlug)) {
+ $childSlug = Str::slug($childTitle);
+ }
+ if (empty($childSlug)) {
+ $childSlug = 'page-'.md5($childTitle);
+ }
+
+ $this->line(" [child] {$childTitle} → {$childSlug}");
+
+ if (! $isDryRun) {
+ $originalChildSlug = $childSlug;
+ $counter = 1;
+ while (Page::withTrashed()->where('slug', $childSlug)->exists()) {
+ $childSlug = "{$originalChildSlug}-{$counter}";
+ $counter++;
+ }
+
+ Page::create([
+ 'title' => $childTitle,
+ 'slug' => $childSlug,
+ 'content' => $childBody,
+ 'status' => Page::STATUS_PUBLISHED,
+ 'meta_description' => $childFm['description'] ?? null,
+ 'parent_id' => $parentPage->id,
+ 'sort_order' => $sortOrder,
+ 'published_at' => now(),
+ 'created_by_user_id' => $user->id,
+ ]);
+ }
+
+ $this->pagesCreated++;
+ $sortOrder++;
+ }
+ }
+
+ private function copyImages(string $imagesPath, bool $isDryRun): void
+ {
+ $this->info("Copying images from: {$imagesPath}");
+
+ $destPath = storage_path('app/public/migrated-images');
+
+ if (! $isDryRun && ! is_dir($destPath)) {
+ File::makeDirectory($destPath, 0755, true);
+ }
+
+ $files = File::allFiles($imagesPath);
+
+ foreach ($files as $file) {
+ $relativePath = $file->getRelativePathname();
+ $destFile = "{$destPath}/{$relativePath}";
+
+ $this->line(" {$relativePath}");
+
+ if (! $isDryRun) {
+ $destDir = dirname($destFile);
+ if (! is_dir($destDir)) {
+ File::makeDirectory($destDir, 0755, true);
+ }
+ File::copy($file->getPathname(), $destFile);
+ }
+
+ $this->imagescopied++;
+ }
+ }
+
+ /**
+ * Parse a markdown file into frontmatter array and body string.
+ */
+ private function parseMarkdownFile(string $filePath): ?array
+ {
+ $content = file_get_contents($filePath);
+ if ($content === false) {
+ return null;
+ }
+
+ // Match YAML frontmatter between --- delimiters
+ if (! preg_match('/\A---\s*\n(.*?)\n---\s*\n?(.*)\z/s', $content, $matches)) {
+ // No frontmatter — treat entire content as body
+ return [
+ 'frontmatter' => [],
+ 'body' => trim($content),
+ ];
+ }
+
+ $yamlString = $matches[1];
+ $body = trim($matches[2]);
+
+ try {
+ // Strip YAML comments (lines starting with #) before parsing
+ $yamlLines = array_filter(
+ explode("\n", $yamlString),
+ fn ($line) => ! preg_match('/^\s*#/', $line)
+ );
+ $cleanYaml = implode("\n", $yamlLines);
+ $frontmatter = Yaml::parse($cleanYaml) ?? [];
+ } catch (\Exception $e) {
+ $this->warn(" YAML parse error in {$filePath}: {$e->getMessage()}");
+ $frontmatter = [];
+ }
+
+ return [
+ 'frontmatter' => $frontmatter,
+ 'body' => $body,
+ ];
+ }
+
+ /**
+ * Parse a date value from Hugo frontmatter.
+ * YAML parser may convert ISO 8601 dates to Unix timestamps (int).
+ *
+ * @param string|int|null $dateValue
+ */
+ private function parseDate(mixed $dateValue): ?\Carbon\Carbon
+ {
+ if ($dateValue === null || $dateValue === '') {
+ return null;
+ }
+
+ try {
+ if (is_int($dateValue) || is_float($dateValue)) {
+ return \Carbon\Carbon::createFromTimestamp((int) $dateValue);
+ }
+
+ return \Carbon\Carbon::parse((string) $dateValue);
+ } catch (\Exception $e) {
+ $this->warn(" Could not parse date: {$dateValue}");
+
+ return null;
+ }
+ }
+
+ /**
+ * Extract a list of values from frontmatter.
+ * Hugo uses both plural array (categories: ["a", "b"]) and singular string (category: "a").
+ */
+ private function extractList(array $frontmatter, string $pluralKey, ?string $singularKey = null): array
+ {
+ $items = [];
+
+ if (! empty($frontmatter[$pluralKey])) {
+ $value = $frontmatter[$pluralKey];
+ $items = is_array($value) ? $value : [$value];
+ } elseif ($singularKey && ! empty($frontmatter[$singularKey])) {
+ $value = $frontmatter[$singularKey];
+ $items = is_array($value) ? $value : [$value];
+ }
+
+ // Clean up strings
+ return array_filter(array_map('trim', $items));
+ }
+
+ private function findOrCreateCategory(string $name): ArticleCategory
+ {
+ $slug = Str::slug($name) ?: 'category-'.mt_rand(100, 999);
+
+ $category = ArticleCategory::where('slug', $slug)->first();
+
+ if (! $category) {
+ $category = ArticleCategory::create([
+ 'name' => $name,
+ 'slug' => $slug,
+ 'sort_order' => 0,
+ ]);
+ $this->categoriesCreated++;
+ $this->line(" Created category: {$name}");
+ }
+
+ return $category;
+ }
+
+ private function findOrCreateTag(string $name): ArticleTag
+ {
+ $slug = Str::slug($name) ?: 'tag-'.mt_rand(100, 999);
+
+ $tag = ArticleTag::where('slug', $slug)->first();
+
+ if (! $tag) {
+ $tag = ArticleTag::create([
+ 'name' => $name,
+ 'slug' => $slug,
+ ]);
+ $this->tagsCreated++;
+ $this->line(" Created tag: {$name}");
+ }
+
+ return $tag;
+ }
+
+ /**
+ * Convert Hugo image paths to migrated storage paths.
+ * Hugo: "images/blog/Update.jpg" → "migrated-images/blog/Update.jpg"
+ */
+ private function resolveImagePath(?string $hugoPath): ?string
+ {
+ if (empty($hugoPath)) {
+ return null;
+ }
+
+ // Remove leading "images/" prefix
+ $relativePath = preg_replace('#^images/#', '', $hugoPath);
+
+ return "migrated-images/{$relativePath}";
+ }
+}
diff --git a/app/Http/Controllers/Admin/ArticleCategoryController.php b/app/Http/Controllers/Admin/ArticleCategoryController.php
new file mode 100644
index 0000000..96d1716
--- /dev/null
+++ b/app/Http/Controllers/Admin/ArticleCategoryController.php
@@ -0,0 +1,112 @@
+middleware('can:view_articles');
+ }
+
+ public function index()
+ {
+ $categories = ArticleCategory::withCount('articles')
+ ->orderBy('sort_order')
+ ->get();
+
+ return view('admin.article-categories.index', compact('categories'));
+ }
+
+ public function create()
+ {
+ return view('admin.article-categories.create');
+ }
+
+ public function store(Request $request)
+ {
+ $validated = $request->validate([
+ 'name' => 'required|string|max:255',
+ 'slug' => 'nullable|string|max:255|unique:article_categories,slug',
+ 'description' => 'nullable|string|max:1000',
+ 'sort_order' => 'nullable|integer',
+ ]);
+
+ $category = ArticleCategory::create([
+ 'name' => $validated['name'],
+ 'slug' => $validated['slug'] ?? null,
+ 'description' => $validated['description'] ?? null,
+ 'sort_order' => $validated['sort_order'] ?? 0,
+ ]);
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'article_category.created',
+ 'description' => "建立文章分類:{$category->name}",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return redirect()
+ ->route('admin.article-categories.index')
+ ->with('status', '分類已成功建立');
+ }
+
+ public function edit(ArticleCategory $articleCategory)
+ {
+ return view('admin.article-categories.edit', ['category' => $articleCategory]);
+ }
+
+ public function update(Request $request, ArticleCategory $articleCategory)
+ {
+ $validated = $request->validate([
+ 'name' => 'required|string|max:255',
+ 'slug' => 'nullable|string|max:255|unique:article_categories,slug,'.$articleCategory->id,
+ 'description' => 'nullable|string|max:1000',
+ 'sort_order' => 'nullable|integer',
+ ]);
+
+ $articleCategory->update([
+ 'name' => $validated['name'],
+ 'slug' => $validated['slug'] ?? $articleCategory->slug,
+ 'description' => $validated['description'] ?? null,
+ 'sort_order' => $validated['sort_order'] ?? 0,
+ ]);
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'article_category.updated',
+ 'description' => "更新文章分類:{$articleCategory->name}",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return redirect()
+ ->route('admin.article-categories.index')
+ ->with('status', '分類已成功更新');
+ }
+
+ public function destroy(ArticleCategory $articleCategory)
+ {
+ if ($articleCategory->articles()->count() > 0) {
+ return back()->with('error', '此分類下仍有文章,無法刪除');
+ }
+
+ $name = $articleCategory->name;
+ $articleCategory->delete();
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'article_category.deleted',
+ 'description' => "刪除文章分類:{$name}",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return redirect()
+ ->route('admin.article-categories.index')
+ ->with('status', '分類已成功刪除');
+ }
+}
diff --git a/app/Http/Controllers/Admin/ArticleController.php b/app/Http/Controllers/Admin/ArticleController.php
new file mode 100644
index 0000000..06681bb
--- /dev/null
+++ b/app/Http/Controllers/Admin/ArticleController.php
@@ -0,0 +1,449 @@
+middleware('can:view_articles')->only(['index', 'show']);
+ $this->middleware('can:create_articles')->only(['create', 'store']);
+ $this->middleware('can:edit_articles')->only(['edit', 'update']);
+ $this->middleware('can:delete_articles')->only(['destroy']);
+ $this->middleware('can:publish_articles')->only(['publish', 'archive']);
+ }
+
+ public function index(Request $request)
+ {
+ $query = Article::with(['creator', 'categories'])
+ ->orderByDesc('is_pinned')
+ ->orderByDesc('created_at');
+
+ if ($request->filled('status')) {
+ $query->where('status', $request->status);
+ }
+
+ if ($request->filled('content_type')) {
+ $query->where('content_type', $request->content_type);
+ }
+
+ if ($request->filled('category')) {
+ $query->whereHas('categories', function ($q) use ($request) {
+ $q->where('article_categories.id', $request->category);
+ });
+ }
+
+ if ($request->filled('search')) {
+ $search = $request->search;
+ $query->where(function ($q) use ($search) {
+ $q->where('title', 'like', "%{$search}%")
+ ->orWhere('content', 'like', "%{$search}%");
+ });
+ }
+
+ $articles = $query->paginate(20);
+
+ $stats = [
+ 'total' => Article::count(),
+ 'draft' => Article::draft()->count(),
+ 'published' => Article::published()->count(),
+ 'archived' => Article::archived()->count(),
+ 'pinned' => Article::pinned()->count(),
+ ];
+
+ $categories = ArticleCategory::orderBy('sort_order')->get();
+
+ return view('admin.articles.index', compact('articles', 'stats', 'categories'));
+ }
+
+ public function create()
+ {
+ $categories = ArticleCategory::orderBy('sort_order')->get();
+ $tags = ArticleTag::orderBy('name')->get();
+
+ return view('admin.articles.create', compact('categories', 'tags'));
+ }
+
+ public function store(Request $request)
+ {
+ $validated = $request->validate([
+ 'title' => 'required|string|max:255',
+ 'slug' => 'nullable|string|max:255|unique:articles,slug',
+ 'summary' => 'nullable|string|max:1000',
+ 'content' => 'required|string',
+ 'content_type' => 'required|in:blog,notice,document,related_news',
+ 'access_level' => 'required|in:public,members,board,admin',
+ 'author_name' => 'nullable|string|max:255',
+ 'meta_description' => 'nullable|string|max:500',
+ 'published_at' => 'nullable|date',
+ 'expires_at' => 'nullable|date|after:published_at',
+ 'is_pinned' => 'boolean',
+ 'display_order' => 'nullable|integer',
+ 'categories' => 'nullable|array',
+ 'categories.*' => 'exists:article_categories,id',
+ 'tags_input' => 'nullable|string',
+ 'featured_image' => 'nullable|image|max:5120',
+ 'featured_image_alt' => 'nullable|string|max:255',
+ 'save_action' => 'required|in:draft,publish',
+ ]);
+
+ $articleData = [
+ 'title' => $validated['title'],
+ 'slug' => $validated['slug'] ?? null,
+ 'summary' => $validated['summary'] ?? null,
+ 'content' => $validated['content'],
+ 'content_type' => $validated['content_type'],
+ 'access_level' => $validated['access_level'],
+ 'author_name' => $validated['author_name'] ?? null,
+ 'meta_description' => $validated['meta_description'] ?? null,
+ 'status' => $validated['save_action'] === 'publish' ? Article::STATUS_PUBLISHED : Article::STATUS_DRAFT,
+ 'published_at' => $validated['save_action'] === 'publish' ? ($validated['published_at'] ?? now()) : ($validated['published_at'] ?? null),
+ 'expires_at' => $validated['expires_at'] ?? null,
+ 'is_pinned' => $validated['is_pinned'] ?? false,
+ 'display_order' => $validated['display_order'] ?? 0,
+ 'created_by_user_id' => auth()->id(),
+ 'last_updated_by_user_id' => auth()->id(),
+ 'featured_image_alt' => $validated['featured_image_alt'] ?? null,
+ ];
+
+ if ($request->hasFile('featured_image')) {
+ $articleData['featured_image_path'] = $request->file('featured_image')->store('articles/images', 'public');
+ }
+
+ $article = Article::create($articleData);
+
+ // Sync categories
+ if (! empty($validated['categories'])) {
+ $article->categories()->sync($validated['categories']);
+ }
+
+ // Handle tags
+ if (! empty($validated['tags_input'])) {
+ $tagNames = array_filter(array_map('trim', explode(',', $validated['tags_input'])));
+ $tagIds = [];
+ foreach ($tagNames as $tagName) {
+ $tag = ArticleTag::firstOrCreate(
+ ['name' => $tagName],
+ ['slug' => Str::slug($tagName) ?: 'tag-'.time()]
+ );
+ $tagIds[] = $tag->id;
+ }
+ $article->tags()->sync($tagIds);
+ }
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'article.created',
+ 'description' => "建立文章:{$article->title} (類型:{$article->getContentTypeLabel()},狀態:{$article->getStatusLabel()})",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ $message = $validated['save_action'] === 'publish' ? '文章已成功發布' : '文章已儲存為草稿';
+
+ return redirect()
+ ->route('admin.articles.show', $article)
+ ->with('status', $message);
+ }
+
+ public function show(Article $article)
+ {
+ if (! $article->canBeViewedBy(auth()->user())) {
+ abort(403, '您沒有權限查看此文章');
+ }
+
+ $article->load(['creator', 'lastUpdatedBy', 'categories', 'tags', 'attachments']);
+
+ return view('admin.articles.show', compact('article'));
+ }
+
+ public function edit(Article $article)
+ {
+ if (! $article->canBeEditedBy(auth()->user())) {
+ abort(403, '您沒有權限編輯此文章');
+ }
+
+ $article->load(['categories', 'tags', 'attachments']);
+ $categories = ArticleCategory::orderBy('sort_order')->get();
+ $tags = ArticleTag::orderBy('name')->get();
+
+ return view('admin.articles.edit', compact('article', 'categories', 'tags'));
+ }
+
+ public function update(Request $request, Article $article)
+ {
+ if (! $article->canBeEditedBy(auth()->user())) {
+ abort(403, '您沒有權限編輯此文章');
+ }
+
+ $validated = $request->validate([
+ 'title' => 'required|string|max:255',
+ 'slug' => 'nullable|string|max:255|unique:articles,slug,'.$article->id,
+ 'summary' => 'nullable|string|max:1000',
+ 'content' => 'required|string',
+ 'content_type' => 'required|in:blog,notice,document,related_news',
+ 'access_level' => 'required|in:public,members,board,admin',
+ 'author_name' => 'nullable|string|max:255',
+ 'meta_description' => 'nullable|string|max:500',
+ 'published_at' => 'nullable|date',
+ 'expires_at' => 'nullable|date|after:published_at',
+ 'is_pinned' => 'boolean',
+ 'display_order' => 'nullable|integer',
+ 'categories' => 'nullable|array',
+ 'categories.*' => 'exists:article_categories,id',
+ 'tags_input' => 'nullable|string',
+ 'featured_image' => 'nullable|image|max:5120',
+ 'featured_image_alt' => 'nullable|string|max:255',
+ 'remove_featured_image' => 'boolean',
+ ]);
+
+ $updateData = [
+ 'title' => $validated['title'],
+ 'summary' => $validated['summary'] ?? null,
+ 'content' => $validated['content'],
+ 'content_type' => $validated['content_type'],
+ 'access_level' => $validated['access_level'],
+ 'author_name' => $validated['author_name'] ?? null,
+ 'meta_description' => $validated['meta_description'] ?? null,
+ 'published_at' => $validated['published_at'],
+ 'expires_at' => $validated['expires_at'] ?? null,
+ 'is_pinned' => $validated['is_pinned'] ?? false,
+ 'display_order' => $validated['display_order'] ?? 0,
+ 'last_updated_by_user_id' => auth()->id(),
+ 'featured_image_alt' => $validated['featured_image_alt'] ?? null,
+ ];
+
+ if (! empty($validated['slug']) && $validated['slug'] !== $article->slug) {
+ $updateData['slug'] = $validated['slug'];
+ }
+
+ if ($request->hasFile('featured_image')) {
+ if ($article->featured_image_path) {
+ Storage::disk('public')->delete($article->featured_image_path);
+ }
+ $updateData['featured_image_path'] = $request->file('featured_image')->store('articles/images', 'public');
+ } elseif ($request->boolean('remove_featured_image') && $article->featured_image_path) {
+ Storage::disk('public')->delete($article->featured_image_path);
+ $updateData['featured_image_path'] = null;
+ }
+
+ $article->update($updateData);
+
+ // Sync categories
+ $article->categories()->sync($validated['categories'] ?? []);
+
+ // Handle tags
+ if (isset($validated['tags_input'])) {
+ $tagNames = array_filter(array_map('trim', explode(',', $validated['tags_input'])));
+ $tagIds = [];
+ foreach ($tagNames as $tagName) {
+ $tag = ArticleTag::firstOrCreate(
+ ['name' => $tagName],
+ ['slug' => Str::slug($tagName) ?: 'tag-'.time()]
+ );
+ $tagIds[] = $tag->id;
+ }
+ $article->tags()->sync($tagIds);
+ } else {
+ $article->tags()->sync([]);
+ }
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'article.updated',
+ 'description' => "更新文章:{$article->title}",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return redirect()
+ ->route('admin.articles.show', $article)
+ ->with('status', '文章已成功更新');
+ }
+
+ public function destroy(Article $article)
+ {
+ if (! $article->canBeEditedBy(auth()->user())) {
+ abort(403, '您沒有權限刪除此文章');
+ }
+
+ $title = $article->title;
+ $article->delete();
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'article.deleted',
+ 'description' => "刪除文章:{$title}",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return redirect()
+ ->route('admin.articles.index')
+ ->with('status', '文章已成功刪除');
+ }
+
+ public function publish(Article $article)
+ {
+ if (! auth()->user()->can('publish_articles')) {
+ abort(403, '您沒有權限發布文章');
+ }
+
+ if (! $article->canBeEditedBy(auth()->user())) {
+ abort(403, '您沒有權限發布此文章');
+ }
+
+ if ($article->isPublished()) {
+ return back()->with('error', '此文章已經發布');
+ }
+
+ $article->publish(auth()->user());
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'article.published',
+ 'description' => "發布文章:{$article->title}",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return back()->with('status', '文章已成功發布');
+ }
+
+ public function archive(Article $article)
+ {
+ if (! auth()->user()->can('publish_articles')) {
+ abort(403, '您沒有權限歸檔文章');
+ }
+
+ if (! $article->canBeEditedBy(auth()->user())) {
+ abort(403, '您沒有權限歸檔此文章');
+ }
+
+ if ($article->isArchived()) {
+ return back()->with('error', '此文章已經歸檔');
+ }
+
+ $article->archive(auth()->user());
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'article.archived',
+ 'description' => "歸檔文章:{$article->title}",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return back()->with('status', '文章已成功歸檔');
+ }
+
+ public function pin(Request $request, Article $article)
+ {
+ if (! auth()->user()->can('edit_articles')) {
+ abort(403, '您沒有權限置頂文章');
+ }
+
+ if (! $article->canBeEditedBy(auth()->user())) {
+ abort(403, '您沒有權限置頂此文章');
+ }
+
+ $validated = $request->validate([
+ 'display_order' => 'nullable|integer',
+ ]);
+
+ $article->pin($validated['display_order'] ?? 0, auth()->user());
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'article.pinned',
+ 'description' => "置頂文章:{$article->title}",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return back()->with('status', '文章已成功置頂');
+ }
+
+ public function unpin(Article $article)
+ {
+ if (! auth()->user()->can('edit_articles')) {
+ abort(403, '您沒有權限取消置頂文章');
+ }
+
+ if (! $article->canBeEditedBy(auth()->user())) {
+ abort(403, '您沒有權限取消置頂此文章');
+ }
+
+ $article->unpin(auth()->user());
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'article.unpinned',
+ 'description' => "取消置頂文章:{$article->title}",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return back()->with('status', '文章已取消置頂');
+ }
+
+ public function uploadAttachment(Request $request, Article $article)
+ {
+ if (! $article->canBeEditedBy(auth()->user())) {
+ abort(403, '您沒有權限上傳附件');
+ }
+
+ $validated = $request->validate([
+ 'attachment' => 'required|file|max:20480',
+ 'description' => 'nullable|string|max:255',
+ ]);
+
+ $file = $request->file('attachment');
+ $path = $file->store('articles/attachments', 'public');
+
+ $attachment = $article->attachments()->create([
+ 'file_path' => $path,
+ 'original_filename' => $file->getClientOriginalName(),
+ 'mime_type' => $file->getMimeType(),
+ 'file_size' => $file->getSize(),
+ 'description' => $validated['description'] ?? null,
+ ]);
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'article.attachment_uploaded',
+ 'description' => "上傳附件至文章「{$article->title}」:{$attachment->original_filename}",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return back()->with('status', '附件已成功上傳');
+ }
+
+ public function deleteAttachment(Article $article, ArticleAttachment $attachment)
+ {
+ if (! $article->canBeEditedBy(auth()->user())) {
+ abort(403, '您沒有權限刪除附件');
+ }
+
+ if ($attachment->article_id !== $article->id) {
+ abort(404);
+ }
+
+ Storage::disk('public')->delete($attachment->file_path);
+
+ $filename = $attachment->original_filename;
+ $attachment->delete();
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'article.attachment_deleted',
+ 'description' => "刪除文章「{$article->title}」的附件:{$filename}",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return back()->with('status', '附件已成功刪除');
+ }
+}
diff --git a/app/Http/Controllers/Admin/ArticleTagController.php b/app/Http/Controllers/Admin/ArticleTagController.php
new file mode 100644
index 0000000..bf5782a
--- /dev/null
+++ b/app/Http/Controllers/Admin/ArticleTagController.php
@@ -0,0 +1,101 @@
+middleware('can:view_articles');
+ }
+
+ public function index()
+ {
+ $tags = ArticleTag::withCount('articles')
+ ->orderBy('name')
+ ->get();
+
+ return view('admin.article-tags.index', compact('tags'));
+ }
+
+ public function create()
+ {
+ return view('admin.article-tags.create');
+ }
+
+ public function store(Request $request)
+ {
+ $validated = $request->validate([
+ 'name' => 'required|string|max:255',
+ 'slug' => 'nullable|string|max:255|unique:article_tags,slug',
+ ]);
+
+ $tag = ArticleTag::create([
+ 'name' => $validated['name'],
+ 'slug' => $validated['slug'] ?? null,
+ ]);
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'article_tag.created',
+ 'description' => "建立文章標籤:{$tag->name}",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return redirect()
+ ->route('admin.article-tags.index')
+ ->with('status', '標籤已成功建立');
+ }
+
+ public function edit(ArticleTag $articleTag)
+ {
+ return view('admin.article-tags.edit', ['tag' => $articleTag]);
+ }
+
+ public function update(Request $request, ArticleTag $articleTag)
+ {
+ $validated = $request->validate([
+ 'name' => 'required|string|max:255',
+ 'slug' => 'nullable|string|max:255|unique:article_tags,slug,'.$articleTag->id,
+ ]);
+
+ $articleTag->update([
+ 'name' => $validated['name'],
+ 'slug' => $validated['slug'] ?? $articleTag->slug,
+ ]);
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'article_tag.updated',
+ 'description' => "更新文章標籤:{$articleTag->name}",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return redirect()
+ ->route('admin.article-tags.index')
+ ->with('status', '標籤已成功更新');
+ }
+
+ public function destroy(ArticleTag $articleTag)
+ {
+ $name = $articleTag->name;
+ $articleTag->articles()->detach();
+ $articleTag->delete();
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'article_tag.deleted',
+ 'description' => "刪除文章標籤:{$name}",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return redirect()
+ ->route('admin.article-tags.index')
+ ->with('status', '標籤已成功刪除');
+ }
+}
diff --git a/app/Http/Controllers/Admin/PageController.php b/app/Http/Controllers/Admin/PageController.php
new file mode 100644
index 0000000..4f7ab1f
--- /dev/null
+++ b/app/Http/Controllers/Admin/PageController.php
@@ -0,0 +1,181 @@
+middleware('can:view_pages')->only(['index', 'show']);
+ $this->middleware('can:create_pages')->only(['create', 'store']);
+ $this->middleware('can:edit_pages')->only(['edit', 'update']);
+ $this->middleware('can:delete_pages')->only(['destroy']);
+ $this->middleware('can:publish_pages')->only(['publish']);
+ }
+
+ public function index()
+ {
+ $pages = Page::with(['creator', 'parent'])
+ ->topLevel()
+ ->orderBy('sort_order')
+ ->get();
+
+ // Also load child pages
+ $pages->load('children');
+
+ return view('admin.pages.index', compact('pages'));
+ }
+
+ public function create()
+ {
+ $parentPages = Page::topLevel()->orderBy('sort_order')->get();
+
+ return view('admin.pages.create', compact('parentPages'));
+ }
+
+ public function store(Request $request)
+ {
+ $validated = $request->validate([
+ 'title' => 'required|string|max:255',
+ 'slug' => 'nullable|string|max:255|unique:pages,slug',
+ 'content' => 'required|string',
+ 'template' => 'nullable|string|max:255',
+ 'status' => 'required|in:draft,published',
+ 'meta_description' => 'nullable|string|max:500',
+ 'parent_id' => 'nullable|exists:pages,id',
+ 'sort_order' => 'nullable|integer',
+ ]);
+
+ $page = Page::create([
+ 'title' => $validated['title'],
+ 'slug' => $validated['slug'] ?? null,
+ 'content' => $validated['content'],
+ 'template' => $validated['template'] ?? null,
+ 'status' => $validated['status'],
+ 'meta_description' => $validated['meta_description'] ?? null,
+ 'parent_id' => $validated['parent_id'] ?? null,
+ 'sort_order' => $validated['sort_order'] ?? 0,
+ 'published_at' => $validated['status'] === 'published' ? now() : null,
+ 'created_by_user_id' => auth()->id(),
+ 'last_updated_by_user_id' => auth()->id(),
+ ]);
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'page.created',
+ 'description' => "建立頁面:{$page->title} (狀態:{$page->getStatusLabel()})",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return redirect()
+ ->route('admin.pages.show', $page)
+ ->with('status', '頁面已成功建立');
+ }
+
+ public function show(Page $page)
+ {
+ $page->load(['creator', 'lastUpdatedBy', 'parent', 'children']);
+
+ return view('admin.pages.show', compact('page'));
+ }
+
+ public function edit(Page $page)
+ {
+ $parentPages = Page::topLevel()
+ ->where('id', '!=', $page->id)
+ ->orderBy('sort_order')
+ ->get();
+
+ return view('admin.pages.edit', compact('page', 'parentPages'));
+ }
+
+ public function update(Request $request, Page $page)
+ {
+ $validated = $request->validate([
+ 'title' => 'required|string|max:255',
+ 'slug' => 'nullable|string|max:255|unique:pages,slug,'.$page->id,
+ 'content' => 'required|string',
+ 'template' => 'nullable|string|max:255',
+ 'status' => 'required|in:draft,published',
+ 'meta_description' => 'nullable|string|max:500',
+ 'parent_id' => 'nullable|exists:pages,id',
+ 'sort_order' => 'nullable|integer',
+ ]);
+
+ $updateData = [
+ 'title' => $validated['title'],
+ 'content' => $validated['content'],
+ 'template' => $validated['template'] ?? null,
+ 'status' => $validated['status'],
+ 'meta_description' => $validated['meta_description'] ?? null,
+ 'parent_id' => $validated['parent_id'] ?? null,
+ 'sort_order' => $validated['sort_order'] ?? 0,
+ 'last_updated_by_user_id' => auth()->id(),
+ ];
+
+ if (! empty($validated['slug']) && $validated['slug'] !== $page->slug) {
+ $updateData['slug'] = $validated['slug'];
+ }
+
+ if ($validated['status'] === 'published' && ! $page->published_at) {
+ $updateData['published_at'] = now();
+ }
+
+ $page->update($updateData);
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'page.updated',
+ 'description' => "更新頁面:{$page->title}",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return redirect()
+ ->route('admin.pages.show', $page)
+ ->with('status', '頁面已成功更新');
+ }
+
+ public function destroy(Page $page)
+ {
+ if ($page->children()->count() > 0) {
+ return back()->with('error', '此頁面下仍有子頁面,無法刪除');
+ }
+
+ $title = $page->title;
+ $page->delete();
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'page.deleted',
+ 'description' => "刪除頁面:{$title}",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return redirect()
+ ->route('admin.pages.index')
+ ->with('status', '頁面已成功刪除');
+ }
+
+ public function publish(Page $page)
+ {
+ if ($page->isPublished()) {
+ return back()->with('error', '此頁面已經發布');
+ }
+
+ $page->publish(auth()->user());
+
+ AuditLog::create([
+ 'user_id' => auth()->id(),
+ 'action' => 'page.published',
+ 'description' => "發布頁面:{$page->title}",
+ 'ip_address' => request()->ip(),
+ ]);
+
+ return back()->with('status', '頁面已成功發布');
+ }
+}
diff --git a/app/Http/Controllers/Api/ArticleController.php b/app/Http/Controllers/Api/ArticleController.php
new file mode 100644
index 0000000..9c85ac1
--- /dev/null
+++ b/app/Http/Controllers/Api/ArticleController.php
@@ -0,0 +1,94 @@
+active()
+ ->forAccessLevel()
+ ->orderByDesc('is_pinned')
+ ->orderByDesc('published_at');
+
+ if ($request->filled('type')) {
+ $query->byContentType($request->type);
+ }
+
+ if ($request->filled('category')) {
+ $query->whereHas('categories', function ($q) use ($request) {
+ $q->where('article_categories.slug', $request->category);
+ });
+ }
+
+ if ($request->filled('tag')) {
+ $query->whereHas('tags', function ($q) use ($request) {
+ $q->where('article_tags.slug', $request->tag);
+ });
+ }
+
+ if ($request->filled('search')) {
+ $search = $request->search;
+ $query->where(function ($q) use ($search) {
+ $q->where('title', 'like', "%{$search}%")
+ ->orWhere('content', 'like', "%{$search}%");
+ });
+ }
+
+ $articles = $query->paginate($request->integer('per_page', 12));
+
+ return ArticleCollectionResource::collection($articles);
+ }
+
+ public function show(string $slug)
+ {
+ $article = Article::with(['categories', 'tags', 'attachments'])
+ ->active()
+ ->forAccessLevel()
+ ->where('slug', $slug)
+ ->firstOrFail();
+
+ $article->incrementViewCount();
+
+ // Get related articles (same content_type, excluding current)
+ $related = Article::active()
+ ->forAccessLevel()
+ ->where('content_type', $article->content_type)
+ ->where('id', '!=', $article->id)
+ ->orderByDesc('published_at')
+ ->limit(4)
+ ->get();
+
+ return response()->json([
+ 'data' => new ArticleResource($article),
+ 'related' => ArticleCollectionResource::collection($related),
+ ]);
+ }
+
+ public function downloadAttachment(string $slug, int $attachmentId)
+ {
+ $article = Article::active()
+ ->forAccessLevel()
+ ->where('slug', $slug)
+ ->firstOrFail();
+
+ $attachment = ArticleAttachment::where('article_id', $article->id)
+ ->findOrFail($attachmentId);
+
+ $attachment->incrementDownloadCount();
+
+ return Storage::disk('public')->download(
+ $attachment->file_path,
+ $attachment->original_filename
+ );
+ }
+}
diff --git a/app/Http/Controllers/Api/HomepageController.php b/app/Http/Controllers/Api/HomepageController.php
new file mode 100644
index 0000000..aee03ae
--- /dev/null
+++ b/app/Http/Controllers/Api/HomepageController.php
@@ -0,0 +1,81 @@
+active()
+ ->forAccessLevel()
+ ->pinned()
+ ->orderBy('display_order')
+ ->limit(5)
+ ->get();
+
+ // Latest articles by type
+ $latestBlog = Article::with(['categories'])
+ ->active()
+ ->forAccessLevel()
+ ->byContentType('blog')
+ ->orderByDesc('published_at')
+ ->limit(6)
+ ->get();
+
+ $latestNotice = Article::with(['categories'])
+ ->active()
+ ->forAccessLevel()
+ ->byContentType('notice')
+ ->orderByDesc('published_at')
+ ->limit(4)
+ ->get();
+
+ $latestDocument = Article::with(['categories'])
+ ->active()
+ ->forAccessLevel()
+ ->byContentType('document')
+ ->orderByDesc('published_at')
+ ->limit(4)
+ ->get();
+
+ $latestRelatedNews = Article::with(['categories'])
+ ->active()
+ ->forAccessLevel()
+ ->byContentType('related_news')
+ ->orderByDesc('published_at')
+ ->limit(4)
+ ->get();
+
+ // About page
+ $aboutPage = Page::published()
+ ->where('slug', 'about')
+ ->first();
+
+ // Categories
+ $categories = ArticleCategory::withCount(['articles' => function ($q) {
+ $q->active()->forAccessLevel();
+ }])
+ ->orderBy('sort_order')
+ ->get();
+
+ return response()->json([
+ 'featured' => ArticleCollectionResource::collection($featured),
+ 'latest_blog' => ArticleCollectionResource::collection($latestBlog),
+ 'latest_notice' => ArticleCollectionResource::collection($latestNotice),
+ 'latest_document' => ArticleCollectionResource::collection($latestDocument),
+ 'latest_related_news' => ArticleCollectionResource::collection($latestRelatedNews),
+ 'about' => $aboutPage ? new PageResource($aboutPage) : null,
+ 'categories' => CategoryResource::collection($categories),
+ ]);
+ }
+}
diff --git a/app/Http/Controllers/Api/PageController.php b/app/Http/Controllers/Api/PageController.php
new file mode 100644
index 0000000..75599d9
--- /dev/null
+++ b/app/Http/Controllers/Api/PageController.php
@@ -0,0 +1,22 @@
+with(['children' => function ($q) {
+ $q->published()->orderBy('sort_order');
+ }])
+ ->where('slug', $slug)
+ ->firstOrFail();
+
+ return new PageResource($page);
+ }
+}
diff --git a/app/Http/Resources/ArticleCollectionResource.php b/app/Http/Resources/ArticleCollectionResource.php
new file mode 100644
index 0000000..7ef6d19
--- /dev/null
+++ b/app/Http/Resources/ArticleCollectionResource.php
@@ -0,0 +1,34 @@
+ $this->id,
+ 'title' => $this->title,
+ 'slug' => $this->slug,
+ 'summary' => $this->summary,
+ 'excerpt' => $this->getExcerpt(200),
+ 'content_type' => $this->content_type,
+ 'content_type_label' => $this->getContentTypeLabel(),
+ 'featured_image_url' => $this->featured_image_url,
+ 'featured_image_alt' => $this->featured_image_alt,
+ 'author_name' => $this->author_name,
+ 'is_pinned' => $this->is_pinned,
+ 'published_at' => $this->published_at?->toIso8601String(),
+ 'categories' => CategoryResource::collection($this->whenLoaded('categories')),
+ 'tags' => $this->whenLoaded('tags', function () {
+ return $this->tags->map(fn ($tag) => [
+ 'name' => $tag->name,
+ 'slug' => $tag->slug,
+ ]);
+ }),
+ ];
+ }
+}
diff --git a/app/Http/Resources/ArticleResource.php b/app/Http/Resources/ArticleResource.php
new file mode 100644
index 0000000..592d1b3
--- /dev/null
+++ b/app/Http/Resources/ArticleResource.php
@@ -0,0 +1,47 @@
+ $this->id,
+ 'title' => $this->title,
+ 'slug' => $this->slug,
+ 'summary' => $this->summary,
+ 'content' => $this->content,
+ 'content_type' => $this->content_type,
+ 'content_type_label' => $this->getContentTypeLabel(),
+ 'featured_image_url' => $this->featured_image_url,
+ 'featured_image_alt' => $this->featured_image_alt,
+ 'author_name' => $this->author_name,
+ 'meta_description' => $this->meta_description,
+ 'meta_keywords' => $this->meta_keywords,
+ 'is_pinned' => $this->is_pinned,
+ 'view_count' => $this->view_count,
+ 'published_at' => $this->published_at?->toIso8601String(),
+ 'categories' => CategoryResource::collection($this->whenLoaded('categories')),
+ 'tags' => $this->whenLoaded('tags', function () {
+ return $this->tags->map(fn ($tag) => [
+ 'id' => $tag->id,
+ 'name' => $tag->name,
+ 'slug' => $tag->slug,
+ ]);
+ }),
+ 'attachments' => $this->whenLoaded('attachments', function () {
+ return $this->attachments->map(fn ($att) => [
+ 'id' => $att->id,
+ 'original_filename' => $att->original_filename,
+ 'mime_type' => $att->mime_type,
+ 'file_size' => $att->file_size,
+ 'description' => $att->description,
+ ]);
+ }),
+ ];
+ }
+}
diff --git a/app/Http/Resources/CategoryResource.php b/app/Http/Resources/CategoryResource.php
new file mode 100644
index 0000000..d9e41f6
--- /dev/null
+++ b/app/Http/Resources/CategoryResource.php
@@ -0,0 +1,20 @@
+ $this->id,
+ 'name' => $this->name,
+ 'slug' => $this->slug,
+ 'description' => $this->description,
+ 'articles_count' => $this->whenCounted('articles'),
+ ];
+ }
+}
diff --git a/app/Http/Resources/PageResource.php b/app/Http/Resources/PageResource.php
new file mode 100644
index 0000000..e7fa671
--- /dev/null
+++ b/app/Http/Resources/PageResource.php
@@ -0,0 +1,25 @@
+ $this->id,
+ 'title' => $this->title,
+ 'slug' => $this->slug,
+ 'content' => $this->content,
+ 'template' => $this->template,
+ 'custom_fields' => $this->custom_fields,
+ 'meta_description' => $this->meta_description,
+ 'meta_keywords' => $this->meta_keywords,
+ 'published_at' => $this->published_at?->toIso8601String(),
+ 'children' => PageResource::collection($this->whenLoaded('children')),
+ ];
+ }
+}
diff --git a/app/Models/Article.php b/app/Models/Article.php
new file mode 100644
index 0000000..5d3901a
--- /dev/null
+++ b/app/Models/Article.php
@@ -0,0 +1,452 @@
+ 'boolean',
+ 'display_order' => 'integer',
+ 'view_count' => 'integer',
+ 'meta_keywords' => 'array',
+ 'published_at' => 'datetime',
+ 'expires_at' => 'datetime',
+ 'archived_at' => 'datetime',
+ ];
+
+ // ==================== Boot ====================
+
+ protected static function boot()
+ {
+ parent::boot();
+
+ static::creating(function (Article $article) {
+ if (empty($article->slug)) {
+ $article->slug = static::generateUniqueSlug($article->title);
+ }
+ });
+ }
+
+ public static function generateUniqueSlug(string $title): string
+ {
+ $slug = Str::slug($title);
+
+ // For Chinese titles, slug may be empty
+ if (empty($slug)) {
+ $slug = Str::slug(Str::ascii($title));
+ }
+ if (empty($slug)) {
+ $slug = 'article-'.time();
+ }
+
+ $originalSlug = $slug;
+ $count = 1;
+ while (static::withTrashed()->where('slug', $slug)->exists()) {
+ $slug = $originalSlug.'-'.$count++;
+ }
+
+ return $slug;
+ }
+
+ // ==================== Relationships ====================
+
+ public function categories()
+ {
+ return $this->belongsToMany(ArticleCategory::class, 'article_category', 'article_id', 'category_id');
+ }
+
+ public function tags()
+ {
+ return $this->belongsToMany(ArticleTag::class, 'article_tag', 'article_id', 'tag_id');
+ }
+
+ public function attachments()
+ {
+ return $this->hasMany(ArticleAttachment::class);
+ }
+
+ public function creator()
+ {
+ return $this->belongsTo(User::class, 'created_by_user_id');
+ }
+
+ public function lastUpdatedBy()
+ {
+ return $this->belongsTo(User::class, 'last_updated_by_user_id');
+ }
+
+ public function authorUser()
+ {
+ return $this->belongsTo(User::class, 'author_user_id');
+ }
+
+ // ==================== Status Check Methods ====================
+
+ public function isDraft(): bool
+ {
+ return $this->status === self::STATUS_DRAFT;
+ }
+
+ public function isPublished(): bool
+ {
+ return $this->status === self::STATUS_PUBLISHED;
+ }
+
+ public function isArchived(): bool
+ {
+ return $this->status === self::STATUS_ARCHIVED;
+ }
+
+ public function isPinned(): bool
+ {
+ return $this->is_pinned;
+ }
+
+ public function isExpired(): bool
+ {
+ if (! $this->expires_at) {
+ return false;
+ }
+
+ return $this->expires_at->isPast();
+ }
+
+ public function isScheduled(): bool
+ {
+ if (! $this->published_at) {
+ return false;
+ }
+
+ return $this->published_at->isFuture();
+ }
+
+ public function isActive(): bool
+ {
+ return $this->isPublished()
+ && ! $this->isExpired()
+ && (! $this->published_at || $this->published_at->isPast());
+ }
+
+ // ==================== Access Control Methods ====================
+
+ public function canBeViewedBy(?User $user): bool
+ {
+ if ($this->isDraft()) {
+ if (! $user) {
+ return false;
+ }
+
+ return $user->id === $this->created_by_user_id
+ || $user->hasRole('admin')
+ || $user->can('manage_all_articles');
+ }
+
+ if ($this->isArchived()) {
+ if (! $user) {
+ return false;
+ }
+
+ return $user->hasRole('admin') || $user->can('manage_all_articles');
+ }
+
+ if ($this->isExpired()) {
+ if (! $user) {
+ return false;
+ }
+
+ return $user->hasRole('admin') || $user->can('manage_all_articles');
+ }
+
+ if ($this->isScheduled()) {
+ if (! $user) {
+ return false;
+ }
+
+ return $user->id === $this->created_by_user_id
+ || $user->hasRole('admin')
+ || $user->can('manage_all_articles');
+ }
+
+ if ($this->access_level === self::ACCESS_LEVEL_PUBLIC) {
+ return true;
+ }
+
+ if (! $user) {
+ return false;
+ }
+
+ if ($user->hasRole('admin')) {
+ return true;
+ }
+
+ if ($this->access_level === self::ACCESS_LEVEL_MEMBERS) {
+ return $user->member && $user->member->hasPaidMembership();
+ }
+
+ if ($this->access_level === self::ACCESS_LEVEL_BOARD) {
+ return $user->hasRole(['admin', 'finance_chair', 'finance_board_member']);
+ }
+
+ if ($this->access_level === self::ACCESS_LEVEL_ADMIN) {
+ return $user->hasRole('admin');
+ }
+
+ return false;
+ }
+
+ public function canBeEditedBy(User $user): bool
+ {
+ if ($user->hasRole('admin') || $user->can('manage_all_articles')) {
+ return true;
+ }
+
+ if (! $user->can('edit_articles')) {
+ return false;
+ }
+
+ return $user->id === $this->created_by_user_id;
+ }
+
+ // ==================== Query Scopes ====================
+
+ public function scopePublished(Builder $query): Builder
+ {
+ return $query->where('status', self::STATUS_PUBLISHED);
+ }
+
+ public function scopeDraft(Builder $query): Builder
+ {
+ return $query->where('status', self::STATUS_DRAFT);
+ }
+
+ public function scopeArchived(Builder $query): Builder
+ {
+ return $query->where('status', self::STATUS_ARCHIVED);
+ }
+
+ public function scopeActive(Builder $query): Builder
+ {
+ return $query->where('status', self::STATUS_PUBLISHED)
+ ->where(function ($q) {
+ $q->whereNull('published_at')
+ ->orWhere('published_at', '<=', now());
+ })
+ ->where(function ($q) {
+ $q->whereNull('expires_at')
+ ->orWhere('expires_at', '>', now());
+ });
+ }
+
+ public function scopeByContentType(Builder $query, string $contentType): Builder
+ {
+ return $query->where('content_type', $contentType);
+ }
+
+ public function scopePinned(Builder $query): Builder
+ {
+ return $query->where('is_pinned', true);
+ }
+
+ public function scopeForAccessLevel(Builder $query, ?User $user = null): Builder
+ {
+ if ($user && $user->hasRole('admin')) {
+ return $query;
+ }
+
+ $accessLevels = [self::ACCESS_LEVEL_PUBLIC];
+
+ if ($user) {
+ if ($user->member && $user->member->hasPaidMembership()) {
+ $accessLevels[] = self::ACCESS_LEVEL_MEMBERS;
+ }
+
+ if ($user->hasRole(['finance_chair', 'finance_board_member'])) {
+ $accessLevels[] = self::ACCESS_LEVEL_BOARD;
+ }
+ }
+
+ return $query->whereIn('access_level', $accessLevels);
+ }
+
+ // ==================== Helper Methods ====================
+
+ public function publish(?User $user = null): void
+ {
+ $updates = [
+ 'status' => self::STATUS_PUBLISHED,
+ ];
+
+ if (! $this->published_at) {
+ $updates['published_at'] = now();
+ }
+
+ if ($user) {
+ $updates['last_updated_by_user_id'] = $user->id;
+ }
+
+ $this->update($updates);
+ }
+
+ public function archive(?User $user = null): void
+ {
+ $updates = [
+ 'status' => self::STATUS_ARCHIVED,
+ 'archived_at' => now(),
+ ];
+
+ if ($user) {
+ $updates['last_updated_by_user_id'] = $user->id;
+ }
+
+ $this->update($updates);
+ }
+
+ public function pin(?int $order = null, ?User $user = null): void
+ {
+ $updates = [
+ 'is_pinned' => true,
+ 'display_order' => $order ?? 0,
+ ];
+
+ if ($user) {
+ $updates['last_updated_by_user_id'] = $user->id;
+ }
+
+ $this->update($updates);
+ }
+
+ public function unpin(?User $user = null): void
+ {
+ $updates = [
+ 'is_pinned' => false,
+ 'display_order' => 0,
+ ];
+
+ if ($user) {
+ $updates['last_updated_by_user_id'] = $user->id;
+ }
+
+ $this->update($updates);
+ }
+
+ public function incrementViewCount(): void
+ {
+ $this->increment('view_count');
+ }
+
+ public function getAccessLevelLabel(): string
+ {
+ return match ($this->access_level) {
+ self::ACCESS_LEVEL_PUBLIC => '公開',
+ self::ACCESS_LEVEL_MEMBERS => '會員',
+ self::ACCESS_LEVEL_BOARD => '理事會',
+ self::ACCESS_LEVEL_ADMIN => '管理員',
+ default => '未知',
+ };
+ }
+
+ public function getStatusLabel(): string
+ {
+ return match ($this->status) {
+ self::STATUS_DRAFT => '草稿',
+ self::STATUS_PUBLISHED => '已發布',
+ self::STATUS_ARCHIVED => '已歸檔',
+ default => '未知',
+ };
+ }
+
+ public function getStatusBadgeColor(): string
+ {
+ return match ($this->status) {
+ self::STATUS_DRAFT => 'gray',
+ self::STATUS_PUBLISHED => 'green',
+ self::STATUS_ARCHIVED => 'yellow',
+ default => 'gray',
+ };
+ }
+
+ public function getContentTypeLabel(): string
+ {
+ return match ($this->content_type) {
+ self::CONTENT_TYPE_BLOG => '部落格',
+ self::CONTENT_TYPE_NOTICE => '公告',
+ self::CONTENT_TYPE_DOCUMENT => '文件',
+ self::CONTENT_TYPE_RELATED_NEWS => '相關新聞',
+ default => '未知',
+ };
+ }
+
+ public function getExcerpt(int $length = 150): string
+ {
+ $plainText = strip_tags($this->summary ?: $this->content);
+
+ return Str::limit($plainText, $length);
+ }
+
+ public function getFeaturedImageUrlAttribute(): ?string
+ {
+ if (! $this->featured_image_path) {
+ return null;
+ }
+
+ return asset('storage/'.$this->featured_image_path);
+ }
+}
diff --git a/app/Models/ArticleAttachment.php b/app/Models/ArticleAttachment.php
new file mode 100644
index 0000000..57b20de
--- /dev/null
+++ b/app/Models/ArticleAttachment.php
@@ -0,0 +1,36 @@
+ 'integer',
+ 'download_count' => 'integer',
+ ];
+
+ public function article()
+ {
+ return $this->belongsTo(Article::class);
+ }
+
+ public function incrementDownloadCount(): void
+ {
+ $this->increment('download_count');
+ }
+}
diff --git a/app/Models/ArticleCategory.php b/app/Models/ArticleCategory.php
new file mode 100644
index 0000000..dc6a67f
--- /dev/null
+++ b/app/Models/ArticleCategory.php
@@ -0,0 +1,48 @@
+ 'integer',
+ ];
+
+ protected static function boot()
+ {
+ parent::boot();
+
+ static::creating(function (ArticleCategory $category) {
+ if (empty($category->slug)) {
+ $slug = Str::slug($category->name);
+ if (empty($slug)) {
+ $slug = 'category-'.time();
+ }
+ $originalSlug = $slug;
+ $count = 1;
+ while (static::where('slug', $slug)->exists()) {
+ $slug = $originalSlug.'-'.$count++;
+ }
+ $category->slug = $slug;
+ }
+ });
+ }
+
+ public function articles()
+ {
+ return $this->belongsToMany(Article::class, 'article_category', 'category_id', 'article_id');
+ }
+}
diff --git a/app/Models/ArticleTag.php b/app/Models/ArticleTag.php
new file mode 100644
index 0000000..cd86e2a
--- /dev/null
+++ b/app/Models/ArticleTag.php
@@ -0,0 +1,42 @@
+slug)) {
+ $slug = Str::slug($tag->name);
+ if (empty($slug)) {
+ $slug = 'tag-'.time();
+ }
+ $originalSlug = $slug;
+ $count = 1;
+ while (static::where('slug', $slug)->exists()) {
+ $slug = $originalSlug.'-'.$count++;
+ }
+ $tag->slug = $slug;
+ }
+ });
+ }
+
+ public function articles()
+ {
+ return $this->belongsToMany(Article::class, 'article_tag', 'tag_id', 'article_id');
+ }
+}
diff --git a/app/Models/Page.php b/app/Models/Page.php
new file mode 100644
index 0000000..024d399
--- /dev/null
+++ b/app/Models/Page.php
@@ -0,0 +1,130 @@
+ 'array',
+ 'meta_keywords' => 'array',
+ 'sort_order' => 'integer',
+ 'published_at' => 'datetime',
+ ];
+
+ protected static function boot()
+ {
+ parent::boot();
+
+ static::creating(function (Page $page) {
+ if (empty($page->slug)) {
+ $slug = Str::slug($page->title);
+ if (empty($slug)) {
+ $slug = 'page-'.time();
+ }
+ $originalSlug = $slug;
+ $count = 1;
+ while (static::withTrashed()->where('slug', $slug)->exists()) {
+ $slug = $originalSlug.'-'.$count++;
+ }
+ $page->slug = $slug;
+ }
+ });
+ }
+
+ // ==================== Relationships ====================
+
+ public function parent()
+ {
+ return $this->belongsTo(Page::class, 'parent_id');
+ }
+
+ public function children()
+ {
+ return $this->hasMany(Page::class, 'parent_id')->orderBy('sort_order');
+ }
+
+ public function creator()
+ {
+ return $this->belongsTo(User::class, 'created_by_user_id');
+ }
+
+ public function lastUpdatedBy()
+ {
+ return $this->belongsTo(User::class, 'last_updated_by_user_id');
+ }
+
+ // ==================== Query Scopes ====================
+
+ public function scopePublished(Builder $query): Builder
+ {
+ return $query->where('status', self::STATUS_PUBLISHED);
+ }
+
+ public function scopeTopLevel(Builder $query): Builder
+ {
+ return $query->whereNull('parent_id');
+ }
+
+ // ==================== Helper Methods ====================
+
+ public function isDraft(): bool
+ {
+ return $this->status === self::STATUS_DRAFT;
+ }
+
+ public function isPublished(): bool
+ {
+ return $this->status === self::STATUS_PUBLISHED;
+ }
+
+ public function publish(?User $user = null): void
+ {
+ $updates = [
+ 'status' => self::STATUS_PUBLISHED,
+ 'published_at' => $this->published_at ?? now(),
+ ];
+
+ if ($user) {
+ $updates['last_updated_by_user_id'] = $user->id;
+ }
+
+ $this->update($updates);
+ }
+
+ public function getStatusLabel(): string
+ {
+ return match ($this->status) {
+ self::STATUS_DRAFT => '草稿',
+ self::STATUS_PUBLISHED => '已發布',
+ default => '未知',
+ };
+ }
+}
diff --git a/config/cors.php b/config/cors.php
index 8a39e6d..4fb6697 100644
--- a/config/cors.php
+++ b/config/cors.php
@@ -19,9 +19,15 @@ return [
'allowed_methods' => ['*'],
- 'allowed_origins' => ['*'],
+ 'allowed_origins' => [
+ 'https://usher.org.tw',
+ 'https://www.usher.org.tw',
+ 'http://localhost:3000',
+ ],
- 'allowed_origins_patterns' => [],
+ 'allowed_origins_patterns' => [
+ 'https://*.vercel.app',
+ ],
'allowed_headers' => ['*'],
diff --git a/database/migrations/2026_02_07_120000_create_article_categories_table.php b/database/migrations/2026_02_07_120000_create_article_categories_table.php
new file mode 100644
index 0000000..135b48a
--- /dev/null
+++ b/database/migrations/2026_02_07_120000_create_article_categories_table.php
@@ -0,0 +1,25 @@
+id();
+ $table->string('name');
+ $table->string('slug')->unique();
+ $table->text('description')->nullable();
+ $table->integer('sort_order')->default(0);
+ $table->timestamps();
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::dropIfExists('article_categories');
+ }
+};
diff --git a/database/migrations/2026_02_07_120001_create_article_tags_table.php b/database/migrations/2026_02_07_120001_create_article_tags_table.php
new file mode 100644
index 0000000..0a4d359
--- /dev/null
+++ b/database/migrations/2026_02_07_120001_create_article_tags_table.php
@@ -0,0 +1,23 @@
+id();
+ $table->string('name');
+ $table->string('slug')->unique();
+ $table->timestamps();
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::dropIfExists('article_tags');
+ }
+};
diff --git a/database/migrations/2026_02_07_120002_create_articles_table.php b/database/migrations/2026_02_07_120002_create_articles_table.php
new file mode 100644
index 0000000..c5b5dc1
--- /dev/null
+++ b/database/migrations/2026_02_07_120002_create_articles_table.php
@@ -0,0 +1,46 @@
+id();
+ $table->string('title');
+ $table->string('slug')->unique();
+ $table->text('summary')->nullable();
+ $table->longText('content');
+ $table->string('content_type'); // blog, notice, document, related_news
+ $table->string('status')->default('draft'); // draft, published, archived
+ $table->string('access_level')->default('public'); // public, members, board, admin
+ $table->string('featured_image_path')->nullable();
+ $table->string('featured_image_alt')->nullable();
+ $table->string('author_name')->nullable();
+ $table->foreignId('author_user_id')->nullable()->constrained('users')->nullOnDelete();
+ $table->text('meta_description')->nullable();
+ $table->json('meta_keywords')->nullable();
+ $table->boolean('is_pinned')->default(false);
+ $table->integer('display_order')->default(0);
+ $table->timestamp('published_at')->nullable();
+ $table->timestamp('expires_at')->nullable();
+ $table->timestamp('archived_at')->nullable();
+ $table->unsignedBigInteger('view_count')->default(0);
+ $table->foreignId('created_by_user_id')->constrained('users')->cascadeOnDelete();
+ $table->foreignId('last_updated_by_user_id')->nullable()->constrained('users')->nullOnDelete();
+ $table->softDeletes();
+ $table->timestamps();
+
+ $table->index(['status', 'content_type', 'published_at']);
+ $table->index('slug');
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::dropIfExists('articles');
+ }
+};
diff --git a/database/migrations/2026_02_07_120003_create_article_category_pivot_table.php b/database/migrations/2026_02_07_120003_create_article_category_pivot_table.php
new file mode 100644
index 0000000..35c6b52
--- /dev/null
+++ b/database/migrations/2026_02_07_120003_create_article_category_pivot_table.php
@@ -0,0 +1,22 @@
+foreignId('article_id')->constrained()->cascadeOnDelete();
+ $table->foreignId('category_id')->constrained('article_categories')->cascadeOnDelete();
+ $table->primary(['article_id', 'category_id']);
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::dropIfExists('article_category');
+ }
+};
diff --git a/database/migrations/2026_02_07_120004_create_article_tag_pivot_table.php b/database/migrations/2026_02_07_120004_create_article_tag_pivot_table.php
new file mode 100644
index 0000000..44818c1
--- /dev/null
+++ b/database/migrations/2026_02_07_120004_create_article_tag_pivot_table.php
@@ -0,0 +1,22 @@
+foreignId('article_id')->constrained()->cascadeOnDelete();
+ $table->foreignId('tag_id')->constrained('article_tags')->cascadeOnDelete();
+ $table->primary(['article_id', 'tag_id']);
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::dropIfExists('article_tag');
+ }
+};
diff --git a/database/migrations/2026_02_07_120005_create_article_attachments_table.php b/database/migrations/2026_02_07_120005_create_article_attachments_table.php
new file mode 100644
index 0000000..74f9665
--- /dev/null
+++ b/database/migrations/2026_02_07_120005_create_article_attachments_table.php
@@ -0,0 +1,28 @@
+id();
+ $table->foreignId('article_id')->constrained()->cascadeOnDelete();
+ $table->string('file_path');
+ $table->string('original_filename');
+ $table->string('mime_type');
+ $table->unsignedBigInteger('file_size');
+ $table->string('description')->nullable();
+ $table->unsignedBigInteger('download_count')->default(0);
+ $table->timestamps();
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::dropIfExists('article_attachments');
+ }
+};
diff --git a/database/migrations/2026_02_07_120006_create_pages_table.php b/database/migrations/2026_02_07_120006_create_pages_table.php
new file mode 100644
index 0000000..7517dd0
--- /dev/null
+++ b/database/migrations/2026_02_07_120006_create_pages_table.php
@@ -0,0 +1,35 @@
+id();
+ $table->string('title');
+ $table->string('slug')->unique();
+ $table->longText('content');
+ $table->string('template')->nullable();
+ $table->json('custom_fields')->nullable();
+ $table->string('status')->default('draft'); // draft, published
+ $table->text('meta_description')->nullable();
+ $table->json('meta_keywords')->nullable();
+ $table->foreignId('parent_id')->nullable()->constrained('pages')->nullOnDelete();
+ $table->integer('sort_order')->default(0);
+ $table->timestamp('published_at')->nullable();
+ $table->foreignId('created_by_user_id')->constrained('users')->cascadeOnDelete();
+ $table->foreignId('last_updated_by_user_id')->nullable()->constrained('users')->nullOnDelete();
+ $table->softDeletes();
+ $table->timestamps();
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::dropIfExists('pages');
+ }
+};
diff --git a/database/seeders/FinancialWorkflowPermissionsSeeder.php b/database/seeders/FinancialWorkflowPermissionsSeeder.php
index 3ce2dfd..6ed1b20 100644
--- a/database/seeders/FinancialWorkflowPermissionsSeeder.php
+++ b/database/seeders/FinancialWorkflowPermissionsSeeder.php
@@ -90,6 +90,21 @@ class FinancialWorkflowPermissionsSeeder extends Seeder
'delete_announcements' => '刪除公告',
'publish_announcements' => '發布公告',
'manage_all_announcements' => '管理所有公告',
+
+ // ===== 官網文章管理權限 =====
+ 'view_articles' => '查看官網文章',
+ 'create_articles' => '建立官網文章',
+ 'edit_articles' => '編輯官網文章',
+ 'delete_articles' => '刪除官網文章',
+ 'publish_articles' => '發布官網文章',
+ 'manage_all_articles' => '管理所有官網文章',
+
+ // ===== 官網頁面管理權限 =====
+ 'view_pages' => '查看官網頁面',
+ 'create_pages' => '建立官網頁面',
+ 'edit_pages' => '編輯官網頁面',
+ 'delete_pages' => '刪除官網頁面',
+ 'publish_pages' => '發布官網頁面',
];
foreach ($permissions as $name => $description) {
@@ -131,6 +146,19 @@ class FinancialWorkflowPermissionsSeeder extends Seeder
'delete_announcements',
'publish_announcements',
'manage_all_announcements',
+ // 官網文章管理
+ 'view_articles',
+ 'create_articles',
+ 'edit_articles',
+ 'delete_articles',
+ 'publish_articles',
+ 'manage_all_articles',
+ // 官網頁面管理
+ 'view_pages',
+ 'create_pages',
+ 'edit_pages',
+ 'delete_pages',
+ 'publish_pages',
],
'description' => '秘書長 - 協會行政負責人,負責初審所有財務申請',
],
@@ -227,6 +255,19 @@ class FinancialWorkflowPermissionsSeeder extends Seeder
'delete_announcements',
'publish_announcements',
'manage_all_announcements',
+ // 官網文章管理
+ 'view_articles',
+ 'create_articles',
+ 'edit_articles',
+ 'delete_articles',
+ 'publish_articles',
+ 'manage_all_articles',
+ // 官網頁面管理
+ 'view_pages',
+ 'create_pages',
+ 'edit_pages',
+ 'delete_pages',
+ 'publish_pages',
],
'description' => '理事長 - 協會負責人,負責核決重大財務支出與會員繳費最終審核',
],
@@ -244,6 +285,11 @@ class FinancialWorkflowPermissionsSeeder extends Seeder
'edit_announcements',
'delete_announcements',
'publish_announcements',
+ // 官網文章管理
+ 'view_articles',
+ 'create_articles',
+ 'edit_articles',
+ 'publish_articles',
],
'description' => '理事 - 理事會成員,協助監督協會運作與審核特定議案',
],
@@ -267,6 +313,11 @@ class FinancialWorkflowPermissionsSeeder extends Seeder
'edit_announcements',
'delete_announcements',
'publish_announcements',
+ // 官網文章管理
+ 'view_articles',
+ 'create_articles',
+ 'edit_articles',
+ 'publish_articles',
],
'description' => '會員管理員 - 專責處理會員入會審核、資料維護與會籍管理',
],
diff --git a/resources/views/admin/article-categories/create.blade.php b/resources/views/admin/article-categories/create.blade.php
new file mode 100644
index 0000000..5d30e65
--- /dev/null
+++ b/resources/views/admin/article-categories/create.blade.php
@@ -0,0 +1,72 @@
+
+
+
+ 新增文章類別
+
+
+
+
+
diff --git a/resources/views/admin/article-categories/edit.blade.php b/resources/views/admin/article-categories/edit.blade.php
new file mode 100644
index 0000000..317f42c
--- /dev/null
+++ b/resources/views/admin/article-categories/edit.blade.php
@@ -0,0 +1,73 @@
+
+
+
+ 編輯文章類別
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/views/admin/article-categories/index.blade.php b/resources/views/admin/article-categories/index.blade.php
new file mode 100644
index 0000000..07ac14e
--- /dev/null
+++ b/resources/views/admin/article-categories/index.blade.php
@@ -0,0 +1,93 @@
+
+
+
+ 文章類別管理
+
+
+
+
+
+ @if (session('status'))
+
+
{{ session('status') }}
+
+ @endif
+
+ @if (session('error'))
+
+
{{ session('error') }}
+
+ @endif
+
+
+
+
+
+
+
+
+
+ | 名稱 |
+ 代碼 |
+ 文章數量 |
+ 排序 |
+ 操作 |
+
+
+
+ @forelse ($categories as $category)
+
+ |
+ {{ $category->name }}
+ @if($category->description)
+ {{ $category->description }}
+ @endif
+ |
+
+ {{ $category->slug }}
+ |
+
+ {{ $category->articles_count ?? 0 }}
+ |
+
+ {{ $category->sort_order }}
+ |
+
+
+ 編輯
+
+
+ |
+
+ @empty
+
+ |
+ 尚無類別資料
+ |
+
+ @endforelse
+
+
+
+
+
+
+
+
diff --git a/resources/views/admin/article-tags/create.blade.php b/resources/views/admin/article-tags/create.blade.php
new file mode 100644
index 0000000..326a2aa
--- /dev/null
+++ b/resources/views/admin/article-tags/create.blade.php
@@ -0,0 +1,67 @@
+
+
+
+ 建立標籤
+
+
+
+
+
+
+ @if (session('status'))
+
+ {{ session('status') }}
+
+ @endif
+
+ @if (session('error'))
+
+ {{ session('error') }}
+
+ @endif
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/views/admin/article-tags/edit.blade.php b/resources/views/admin/article-tags/edit.blade.php
new file mode 100644
index 0000000..8549c7a
--- /dev/null
+++ b/resources/views/admin/article-tags/edit.blade.php
@@ -0,0 +1,75 @@
+
+
+
+ 編輯標籤
+
+
+
+
+
+
+ @if (session('status'))
+
+ {{ session('status') }}
+
+ @endif
+
+ @if (session('error'))
+
+ {{ session('error') }}
+
+ @endif
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/views/admin/article-tags/index.blade.php b/resources/views/admin/article-tags/index.blade.php
new file mode 100644
index 0000000..647c81a
--- /dev/null
+++ b/resources/views/admin/article-tags/index.blade.php
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
+
+ @if (session('status'))
+
+ {{ session('status') }}
+
+ @endif
+
+ @if (session('error'))
+
+ {{ session('error') }}
+
+ @endif
+
+
+
+
+
+
+ |
+ 名稱
+ |
+
+ 網址代碼
+ |
+
+ 文章數
+ |
+
+ 操作
+ |
+
+
+
+ @forelse ($tags as $tag)
+
+ |
+ {{ $tag->name }}
+ |
+
+ {{ $tag->slug }}
+ |
+
+ {{ $tag->articles_count ?? 0 }}
+ |
+
+
+ 編輯
+
+
+ |
+
+ @empty
+
+ |
+ 尚無標籤資料
+ |
+
+ @endforelse
+
+
+
+
+
+
+
+
diff --git a/resources/views/admin/articles/create.blade.php b/resources/views/admin/articles/create.blade.php
new file mode 100644
index 0000000..aa5a7f6
--- /dev/null
+++ b/resources/views/admin/articles/create.blade.php
@@ -0,0 +1,242 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @push('styles')
+
+ @endpush
+
+ @push('scripts')
+
+
+ @endpush
+
diff --git a/resources/views/admin/articles/edit.blade.php b/resources/views/admin/articles/edit.blade.php
new file mode 100644
index 0000000..f6e3a5a
--- /dev/null
+++ b/resources/views/admin/articles/edit.blade.php
@@ -0,0 +1,284 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
附件管理
+
+ @if($article->attachments->count() > 0)
+
+ @foreach($article->attachments as $attachment)
+
+
+ {{ $attachment->original_filename }}
+ {{ number_format($attachment->file_size / 1024, 1) }} KB
+
+
+
+ @endforeach
+
+ @endif
+
+
+
+
+
+
+ @push('styles')
+
+ @endpush
+
+ @push('scripts')
+
+
+ @endpush
+
diff --git a/resources/views/admin/articles/index.blade.php b/resources/views/admin/articles/index.blade.php
new file mode 100644
index 0000000..77ad99e
--- /dev/null
+++ b/resources/views/admin/articles/index.blade.php
@@ -0,0 +1,184 @@
+
+
+
+
+
+
+
+ @if (session('status'))
+
+
{{ session('status') }}
+
+ @endif
+
+ @if (session('error'))
+
+
{{ session('error') }}
+
+ @endif
+
+
+
+
+
總計
+
{{ $stats['total'] }}
+
+
+
草稿
+
{{ $stats['draft'] }}
+
+
+
已發布
+
{{ $stats['published'] }}
+
+
+
已歸檔
+
{{ $stats['archived'] }}
+
+
+
置頂中
+
{{ $stats['pinned'] }}
+
+
+
+
+
+
+
+
+
+
共 {{ $articles->total() }} 篇文章
+
+
+
+
+
+
+
+ | 文章 |
+ 類型 |
+ 狀態 |
+ 建立者 |
+ 瀏覽 |
+ 建立時間 |
+ 操作 |
+
+
+
+ @forelse($articles as $article)
+
+
+
+ @if($article->is_pinned)
+ 📌
+ @endif
+
+
+
+ {{ Str::limit(strip_tags($article->content), 60) }}
+
+
+
+ |
+
+ {{ $article->getContentTypeLabel() }}
+ |
+
+
+ {{ $article->getStatusLabel() }}
+
+ |
+
+ {{ $article->creator->name ?? 'N/A' }}
+ |
+
+ {{ $article->view_count }}
+ |
+
+ {{ $article->created_at->format('Y-m-d H:i') }}
+ |
+
+ 查看
+ @if($article->canBeEditedBy(auth()->user()))
+ 編輯
+ @endif
+ |
+
+ @empty
+
+ |
+ 沒有找到文章。建立第一篇文章
+ |
+
+ @endforelse
+
+
+
+
+ @if($articles->hasPages())
+
+ {{ $articles->links() }}
+
+ @endif
+
+
+
diff --git a/resources/views/admin/articles/show.blade.php b/resources/views/admin/articles/show.blade.php
new file mode 100644
index 0000000..ed45489
--- /dev/null
+++ b/resources/views/admin/articles/show.blade.php
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+
+ @if (session('status'))
+
+
{{ session('status') }}
+
+ @endif
+
+ @if (session('error'))
+
+
{{ session('error') }}
+
+ @endif
+
+
+
+
+
+
+ @if($article->is_pinned)
+ 📌
+ @endif
+ {{ $article->title }}
+
+
+
+ {{ $article->getContentTypeLabel() }}
+
+
+ {{ $article->getStatusLabel() }}
+
+
+
+
+ @if($article->featured_image_path)
+
+

+
+ @endif
+
+ @if($article->summary)
+
+
摘要
+
{{ $article->summary }}
+
+ @endif
+
+
+
{{ $article->content }}
+
+
+
+ @if($article->categories->count() > 0)
+
+ 分類:
+ @foreach($article->categories as $category)
+ {{ $category->name }}
+ @endforeach
+
+ @endif
+
+ @if($article->tags->count() > 0)
+
+ 標籤:
+ @foreach($article->tags as $tag)
+ {{ $tag->name }}
+ @endforeach
+
+ @endif
+
+
+
+ @if($article->attachments->count() > 0)
+
+
附件
+
+ @foreach($article->attachments as $attachment)
+
+
+ {{ $attachment->original_filename }}
+ {{ number_format($attachment->file_size / 1024, 1) }} KB
+ @if($attachment->description)
+ - {{ $attachment->description }}
+ @endif
+
+
下載 {{ $attachment->download_count }} 次
+
+ @endforeach
+
+
+ @endif
+
+
+
+
文章資訊
+
+
+
- 存取權限
+ - {{ $article->getAccessLevelLabel() }}
+
+
+
- 瀏覽次數
+ - {{ $article->view_count }}
+
+ @if($article->author_name)
+
+
- 作者
+ - {{ $article->author_name }}
+
+ @endif
+
+
- 建立者
+ - {{ $article->creator->name ?? 'N/A' }}
+
+
+
- 網址代碼
+ - {{ $article->slug }}
+
+
+
- 建立時間
+ - {{ $article->created_at->format('Y-m-d H:i:s') }}
+
+ @if($article->published_at)
+
+
- 發布時間
+ -
+ {{ $article->published_at->format('Y-m-d H:i:s') }}
+ @if($article->isScheduled())
+ 排程中
+ @endif
+
+
+ @endif
+ @if($article->expires_at)
+
+
- 過期時間
+ -
+ {{ $article->expires_at->format('Y-m-d H:i:s') }}
+ @if($article->isExpired())
+ 已過期
+ @endif
+
+
+ @endif
+ @if($article->lastUpdatedBy)
+
+
- 最後更新者
+ - {{ $article->lastUpdatedBy->name }}
+
+
+
- 最後更新時間
+ - {{ $article->updated_at->format('Y-m-d H:i:s') }}
+
+ @endif
+ @if($article->meta_description)
+
+
- SEO 描述
+ - {{ $article->meta_description }}
+
+ @endif
+
+
+
+
+ @if($article->canBeEditedBy(auth()->user()))
+
+
操作
+
+ @if($article->isDraft() && auth()->user()->can('publish_articles'))
+
+ @endif
+
+ @if($article->isPublished() && auth()->user()->can('publish_articles'))
+
+ @endif
+
+ @if(!$article->is_pinned && auth()->user()->can('edit_articles'))
+
+ @endif
+
+ @if($article->is_pinned && auth()->user()->can('edit_articles'))
+
+ @endif
+
+ @if(auth()->user()->can('delete_articles'))
+
+ @endif
+
+
+ @endif
+
+
+
diff --git a/resources/views/admin/pages/create.blade.php b/resources/views/admin/pages/create.blade.php
new file mode 100644
index 0000000..4aa6eb3
--- /dev/null
+++ b/resources/views/admin/pages/create.blade.php
@@ -0,0 +1,131 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @push('styles')
+
+ @endpush
+
+ @push('scripts')
+
+
+ @endpush
+
diff --git a/resources/views/admin/pages/edit.blade.php b/resources/views/admin/pages/edit.blade.php
new file mode 100644
index 0000000..3045a67
--- /dev/null
+++ b/resources/views/admin/pages/edit.blade.php
@@ -0,0 +1,135 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @push('styles')
+
+ @endpush
+
+ @push('scripts')
+
+
+ @endpush
+
diff --git a/resources/views/admin/pages/index.blade.php b/resources/views/admin/pages/index.blade.php
new file mode 100644
index 0000000..3255087
--- /dev/null
+++ b/resources/views/admin/pages/index.blade.php
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+ @if (session('status'))
+
+
{{ session('status') }}
+
+ @endif
+
+ @if (session('error'))
+
+
{{ session('error') }}
+
+ @endif
+
+
+
+
+
+ | 頁面 |
+ 網址代碼 |
+ 狀態 |
+ 排序 |
+ 建立者 |
+ 操作 |
+
+
+
+ @forelse($pages as $page)
+
+ |
+
+ @if($page->template)
+ 模板:{{ $page->template }}
+ @endif
+ |
+
+ {{ $page->slug }}
+ |
+
+
+ {{ $page->getStatusLabel() }}
+
+ |
+
+ {{ $page->sort_order }}
+ |
+
+ {{ $page->creator->name ?? 'N/A' }}
+ |
+
+ 查看
+ 編輯
+ |
+
+ {{-- Child pages --}}
+ @foreach($page->children as $child)
+
+ |
+
+ |
+
+ {{ $child->slug }}
+ |
+
+
+ {{ $child->getStatusLabel() }}
+
+ |
+
+ {{ $child->sort_order }}
+ |
+
+ {{ $child->creator->name ?? 'N/A' }}
+ |
+
+ 查看
+ 編輯
+ |
+
+ @endforeach
+ @empty
+
+ |
+ 沒有找到頁面。建立第一個頁面
+ |
+
+ @endforelse
+
+
+
+
+
+
diff --git a/resources/views/admin/pages/show.blade.php b/resources/views/admin/pages/show.blade.php
new file mode 100644
index 0000000..f65e20c
--- /dev/null
+++ b/resources/views/admin/pages/show.blade.php
@@ -0,0 +1,155 @@
+
+
+
+
+
+
+
+ @if (session('status'))
+
+
{{ session('status') }}
+
+ @endif
+
+ @if (session('error'))
+
+
{{ session('error') }}
+
+ @endif
+
+
+
+
+
+
+ {{ $page->title }}
+
+
+ {{ $page->getStatusLabel() }}
+
+
+
+
+
+
+
+
+ @if($page->children->count() > 0)
+
+
子頁面
+
+ @foreach($page->children as $child)
+
+ @endforeach
+
+
+ @endif
+
+
+
+
頁面資訊
+
+
+
- 網址代碼
+ - {{ $page->slug }}
+
+ @if($page->template)
+
+
- 模板
+ - {{ $page->template }}
+
+ @endif
+ @if($page->parent)
+
+ @endif
+
+
- 排序
+ - {{ $page->sort_order }}
+
+
+
- 建立者
+ - {{ $page->creator->name ?? 'N/A' }}
+
+
+
- 建立時間
+ - {{ $page->created_at->format('Y-m-d H:i:s') }}
+
+ @if($page->published_at)
+
+
- 發布時間
+ - {{ $page->published_at->format('Y-m-d H:i:s') }}
+
+ @endif
+ @if($page->lastUpdatedBy)
+
+
- 最後更新者
+ - {{ $page->lastUpdatedBy->name }}
+
+ @endif
+ @if($page->meta_description)
+
+
- SEO 描述
+ - {{ $page->meta_description }}
+
+ @endif
+
+
+
+
+
+
操作
+
+ @if($page->isDraft() && auth()->user()->can('publish_pages'))
+
+ @endif
+
+ @if(auth()->user()->can('delete_pages'))
+
+ @endif
+
+
+
+
+
diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php
index 7950ccf..a0afc31 100644
--- a/resources/views/layouts/app.blade.php
+++ b/resources/views/layouts/app.blade.php
@@ -13,6 +13,8 @@
@vite(['resources/css/app.css', 'resources/js/app.js'])
+
+ @stack('styles')
@@ -35,5 +37,7 @@
{{ $slot }}
+
+ @stack('scripts')