Add headless CMS for official site content management
Integrate article and page management into the Laravel admin dashboard
to serve as a headless CMS for the Next.js frontend (usher-site).
Backend:
- 7 migrations: article_categories, article_tags, articles, pivots, attachments, pages
- 5 models with relationships: Article, ArticleCategory, ArticleTag, ArticleAttachment, Page
- 4 admin controllers: articles (with publish/archive/pin), categories, tags, pages
- Admin views with EasyMDE markdown editor, multi-select categories/tags
- Navigation section "官網管理" in admin sidebar
API (v1):
- GET /api/v1/articles (filtered by type, category, tag, search; paginated)
- GET /api/v1/articles/{slug} (with related articles)
- GET /api/v1/categories
- GET /api/v1/pages/{slug} (with children)
- GET /api/v1/homepage (aggregated homepage data)
- Attachment download endpoint
- CORS configured for usher.org.tw, vercel.app, localhost:3000
Content migration:
- ImportHugoContent command: imports Hugo markdown files as articles/pages
- Successfully imported 27 articles, 17 categories, 11 tags, 9 pages
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
98
CLAUDE.md
98
CLAUDE.md
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|||||||
|
|
||||||
## Project Overview
|
## 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
|
## Commands
|
||||||
|
|
||||||
@@ -28,21 +28,40 @@ php artisan db:seed --class=FinancialWorkflowTestDataSeeder # Finance test data
|
|||||||
./vendor/bin/phpstan analyse # Static analysis
|
./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
|
## 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
|
### 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
|
- **Small (<5,000)**: Secretary approval only
|
||||||
- **Medium (5,000-50,000)**: Secretary → Chair
|
- **Medium (5,000-50,000)**: Secretary → Chair
|
||||||
- **Large (>50,000)**: Secretary → Chair → Board
|
- **Large (>50,000)**: Secretary → Chair → Board
|
||||||
|
|
||||||
Finance documents follow a 3-stage lifecycle:
|
Finance documents follow a 3-stage lifecycle with separate status fields:
|
||||||
1. **Approval Stage**: Multi-tier approval based on amount
|
1. **Approval Stage** (`status`): Multi-tier approval based on amount
|
||||||
2. **Disbursement Stage**: Dual confirmation (requester + cashier)
|
2. **Disbursement Stage** (`disbursement_status`): Dual confirmation (requester + cashier)
|
||||||
3. **Recording Stage**: Accountant records to ledger
|
3. **Recording Stage** (`recording_status`): Accountant records to ledger
|
||||||
|
|
||||||
Key model methods for workflow state:
|
|
||||||
```php
|
```php
|
||||||
$doc->isApprovalComplete() // All required approvals obtained
|
$doc->isApprovalComplete() // All required approvals obtained
|
||||||
$doc->isDisbursementComplete() // Both parties confirmed
|
$doc->isDisbursementComplete() // Both parties confirmed
|
||||||
@@ -50,40 +69,61 @@ $doc->isRecordingComplete() // Ledger entry created
|
|||||||
$doc->isFullyProcessed() // All 3 stages complete
|
$doc->isFullyProcessed() // All 3 stages complete
|
||||||
```
|
```
|
||||||
|
|
||||||
### RBAC Structure
|
### Shared Traits
|
||||||
|
|
||||||
Uses Spatie Laravel Permission. Core financial roles:
|
- **`HasApprovalWorkflow`**: Multi-tier approval with self-approval prevention (`isSelfApproval()`)
|
||||||
- `finance_requester`: Submit finance documents
|
- **`HasAccountingEntries`**: Double-entry bookkeeping, auto-generation, balance validation
|
||||||
- `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.
|
|
||||||
|
|
||||||
### Service Layer
|
### Service Layer
|
||||||
|
|
||||||
Complex business logic lives in `app/Services/`:
|
Complex business logic in `app/Services/`:
|
||||||
- `MembershipFeeCalculator`: Calculates fees with disability discount support
|
- `MembershipFeeCalculator`: Fees with disability discount support
|
||||||
- `SettingsService`: System-wide settings with caching
|
- `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
|
### Data Security Patterns
|
||||||
|
|
||||||
- **National ID**: AES-256 encrypted (`national_id_encrypted`), SHA256 hashed for search (`national_id_hash`)
|
- **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 methods
|
- **File uploads**: Private disk storage, served via authenticated controller
|
||||||
- **Audit logging**: All significant actions logged to `audit_logs` table
|
- **Audit logging**: `AuditLogger::log($action, $auditable, $metadata)` — static class, call in controllers
|
||||||
|
|
||||||
### Member Lifecycle
|
### Member Lifecycle
|
||||||
|
|
||||||
States: `pending` → `active` → `expired` / `suspended`
|
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
|
```php
|
||||||
$member->hasPaidMembership() // Active with future expiry
|
$member->hasPaidMembership() // Active with future expiry
|
||||||
$member->canSubmitPayment() // Pending with no pending payment
|
$member->canSubmitPayment() // Pending with no pending payment
|
||||||
$member->getNextFeeType() // entrance_fee or annual_fee
|
$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
|
### Testing Patterns
|
||||||
|
|
||||||
Tests use `RefreshDatabase` trait. Setup commonly includes:
|
Tests use `RefreshDatabase` trait. Setup commonly includes:
|
||||||
@@ -104,8 +144,12 @@ Test accounts (password: `password`):
|
|||||||
|
|
||||||
## Key Files
|
## Key Files
|
||||||
|
|
||||||
- `routes/web.php` - All web routes (admin routes under `/admin` prefix)
|
- `routes/web.php` — All web routes (admin routes under `/admin` prefix)
|
||||||
- `app/Models/FinanceDocument.php` - Core financial workflow logic with status constants
|
- `config/accounting.php` — Account codes, amount tier thresholds, currency settings
|
||||||
- `app/Models/Member.php` - Member lifecycle with encrypted field handling
|
- `app/Models/FinanceDocument.php` — Core financial workflow logic with 27+ status constants
|
||||||
- `database/seeders/` - RoleSeeder, ChartOfAccountSeeder, TestDataSeeder
|
- `app/Models/Member.php` — Member lifecycle with encrypted field handling
|
||||||
- `docs/SYSTEM_SPECIFICATION.md` - Complete system specification
|
- `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
|
||||||
|
|||||||
527
app/Console/Commands/ImportHugoContent.php
Normal file
527
app/Console/Commands/ImportHugoContent.php
Normal file
@@ -0,0 +1,527 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\Article;
|
||||||
|
use App\Models\ArticleCategory;
|
||||||
|
use App\Models\ArticleTag;
|
||||||
|
use App\Models\Page;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
|
class ImportHugoContent extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'hugo:import
|
||||||
|
{--path= : Path to Hugo content/zh directory}
|
||||||
|
{--images= : Path to Hugo static/images directory}
|
||||||
|
{--dry-run : Preview import without writing to database}';
|
||||||
|
|
||||||
|
protected $description = 'Import Hugo site content (markdown files) into CMS articles and pages';
|
||||||
|
|
||||||
|
private int $articlesCreated = 0;
|
||||||
|
|
||||||
|
private int $pagesCreated = 0;
|
||||||
|
|
||||||
|
private int $categoriesCreated = 0;
|
||||||
|
|
||||||
|
private int $tagsCreated = 0;
|
||||||
|
|
||||||
|
private int $imagescopied = 0;
|
||||||
|
|
||||||
|
private int $skipped = 0;
|
||||||
|
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
$contentPath = $this->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}";
|
||||||
|
}
|
||||||
|
}
|
||||||
112
app/Http/Controllers/Admin/ArticleCategoryController.php
Normal file
112
app/Http/Controllers/Admin/ArticleCategoryController.php
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\ArticleCategory;
|
||||||
|
use App\Models\AuditLog;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ArticleCategoryController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->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', '分類已成功刪除');
|
||||||
|
}
|
||||||
|
}
|
||||||
449
app/Http/Controllers/Admin/ArticleController.php
Normal file
449
app/Http/Controllers/Admin/ArticleController.php
Normal file
@@ -0,0 +1,449 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Article;
|
||||||
|
use App\Models\ArticleAttachment;
|
||||||
|
use App\Models\ArticleCategory;
|
||||||
|
use App\Models\ArticleTag;
|
||||||
|
use App\Models\AuditLog;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class ArticleController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->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', '附件已成功刪除');
|
||||||
|
}
|
||||||
|
}
|
||||||
101
app/Http/Controllers/Admin/ArticleTagController.php
Normal file
101
app/Http/Controllers/Admin/ArticleTagController.php
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\ArticleTag;
|
||||||
|
use App\Models\AuditLog;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ArticleTagController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->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', '標籤已成功刪除');
|
||||||
|
}
|
||||||
|
}
|
||||||
181
app/Http/Controllers/Admin/PageController.php
Normal file
181
app/Http/Controllers/Admin/PageController.php
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\AuditLog;
|
||||||
|
use App\Models\Page;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class PageController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->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', '頁面已成功發布');
|
||||||
|
}
|
||||||
|
}
|
||||||
94
app/Http/Controllers/Api/ArticleController.php
Normal file
94
app/Http/Controllers/Api/ArticleController.php
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Resources\ArticleCollectionResource;
|
||||||
|
use App\Http\Resources\ArticleResource;
|
||||||
|
use App\Models\Article;
|
||||||
|
use App\Models\ArticleAttachment;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class ArticleController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$query = Article::with(['categories', 'tags'])
|
||||||
|
->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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
81
app/Http/Controllers/Api/HomepageController.php
Normal file
81
app/Http/Controllers/Api/HomepageController.php
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Resources\ArticleCollectionResource;
|
||||||
|
use App\Http\Resources\CategoryResource;
|
||||||
|
use App\Http\Resources\PageResource;
|
||||||
|
use App\Models\Article;
|
||||||
|
use App\Models\ArticleCategory;
|
||||||
|
use App\Models\Page;
|
||||||
|
|
||||||
|
class HomepageController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
// Featured/pinned articles
|
||||||
|
$featured = Article::with(['categories', 'tags'])
|
||||||
|
->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),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
22
app/Http/Controllers/Api/PageController.php
Normal file
22
app/Http/Controllers/Api/PageController.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Resources\PageResource;
|
||||||
|
use App\Models\Page;
|
||||||
|
|
||||||
|
class PageController extends Controller
|
||||||
|
{
|
||||||
|
public function show(string $slug)
|
||||||
|
{
|
||||||
|
$page = Page::published()
|
||||||
|
->with(['children' => function ($q) {
|
||||||
|
$q->published()->orderBy('sort_order');
|
||||||
|
}])
|
||||||
|
->where('slug', $slug)
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
return new PageResource($page);
|
||||||
|
}
|
||||||
|
}
|
||||||
34
app/Http/Resources/ArticleCollectionResource.php
Normal file
34
app/Http/Resources/ArticleCollectionResource.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class ArticleCollectionResource extends JsonResource
|
||||||
|
{
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $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,
|
||||||
|
]);
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
47
app/Http/Resources/ArticleResource.php
Normal file
47
app/Http/Resources/ArticleResource.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class ArticleResource extends JsonResource
|
||||||
|
{
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $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,
|
||||||
|
]);
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
20
app/Http/Resources/CategoryResource.php
Normal file
20
app/Http/Resources/CategoryResource.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class CategoryResource extends JsonResource
|
||||||
|
{
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'name' => $this->name,
|
||||||
|
'slug' => $this->slug,
|
||||||
|
'description' => $this->description,
|
||||||
|
'articles_count' => $this->whenCounted('articles'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
25
app/Http/Resources/PageResource.php
Normal file
25
app/Http/Resources/PageResource.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class PageResource extends JsonResource
|
||||||
|
{
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $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')),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
452
app/Models/Article.php
Normal file
452
app/Models/Article.php
Normal file
@@ -0,0 +1,452 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class Article extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, SoftDeletes;
|
||||||
|
|
||||||
|
// ==================== Constants ====================
|
||||||
|
|
||||||
|
const STATUS_DRAFT = 'draft';
|
||||||
|
|
||||||
|
const STATUS_PUBLISHED = 'published';
|
||||||
|
|
||||||
|
const STATUS_ARCHIVED = 'archived';
|
||||||
|
|
||||||
|
const ACCESS_LEVEL_PUBLIC = 'public';
|
||||||
|
|
||||||
|
const ACCESS_LEVEL_MEMBERS = 'members';
|
||||||
|
|
||||||
|
const ACCESS_LEVEL_BOARD = 'board';
|
||||||
|
|
||||||
|
const ACCESS_LEVEL_ADMIN = 'admin';
|
||||||
|
|
||||||
|
const CONTENT_TYPE_BLOG = 'blog';
|
||||||
|
|
||||||
|
const CONTENT_TYPE_NOTICE = 'notice';
|
||||||
|
|
||||||
|
const CONTENT_TYPE_DOCUMENT = 'document';
|
||||||
|
|
||||||
|
const CONTENT_TYPE_RELATED_NEWS = 'related_news';
|
||||||
|
|
||||||
|
// ==================== Configuration ====================
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'title',
|
||||||
|
'slug',
|
||||||
|
'summary',
|
||||||
|
'content',
|
||||||
|
'content_type',
|
||||||
|
'status',
|
||||||
|
'access_level',
|
||||||
|
'featured_image_path',
|
||||||
|
'featured_image_alt',
|
||||||
|
'author_name',
|
||||||
|
'author_user_id',
|
||||||
|
'meta_description',
|
||||||
|
'meta_keywords',
|
||||||
|
'is_pinned',
|
||||||
|
'display_order',
|
||||||
|
'published_at',
|
||||||
|
'expires_at',
|
||||||
|
'archived_at',
|
||||||
|
'view_count',
|
||||||
|
'created_by_user_id',
|
||||||
|
'last_updated_by_user_id',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'is_pinned' => '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);
|
||||||
|
}
|
||||||
|
}
|
||||||
36
app/Models/ArticleAttachment.php
Normal file
36
app/Models/ArticleAttachment.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ArticleAttachment extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'article_id',
|
||||||
|
'file_path',
|
||||||
|
'original_filename',
|
||||||
|
'mime_type',
|
||||||
|
'file_size',
|
||||||
|
'description',
|
||||||
|
'download_count',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'file_size' => 'integer',
|
||||||
|
'download_count' => 'integer',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function article()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Article::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function incrementDownloadCount(): void
|
||||||
|
{
|
||||||
|
$this->increment('download_count');
|
||||||
|
}
|
||||||
|
}
|
||||||
48
app/Models/ArticleCategory.php
Normal file
48
app/Models/ArticleCategory.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class ArticleCategory extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'slug',
|
||||||
|
'description',
|
||||||
|
'sort_order',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'sort_order' => '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');
|
||||||
|
}
|
||||||
|
}
|
||||||
42
app/Models/ArticleTag.php
Normal file
42
app/Models/ArticleTag.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class ArticleTag extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'slug',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected static function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
|
||||||
|
static::creating(function (ArticleTag $tag) {
|
||||||
|
if (empty($tag->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');
|
||||||
|
}
|
||||||
|
}
|
||||||
130
app/Models/Page.php
Normal file
130
app/Models/Page.php
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class Page extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, SoftDeletes;
|
||||||
|
|
||||||
|
const STATUS_DRAFT = 'draft';
|
||||||
|
|
||||||
|
const STATUS_PUBLISHED = 'published';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'title',
|
||||||
|
'slug',
|
||||||
|
'content',
|
||||||
|
'template',
|
||||||
|
'custom_fields',
|
||||||
|
'status',
|
||||||
|
'meta_description',
|
||||||
|
'meta_keywords',
|
||||||
|
'parent_id',
|
||||||
|
'sort_order',
|
||||||
|
'published_at',
|
||||||
|
'created_by_user_id',
|
||||||
|
'last_updated_by_user_id',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'custom_fields' => '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 => '未知',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,9 +19,15 @@ return [
|
|||||||
|
|
||||||
'allowed_methods' => ['*'],
|
'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' => ['*'],
|
'allowed_headers' => ['*'],
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('article_categories', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('article_tags', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('slug')->unique();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('article_tags');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('articles', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('article_category', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('article_tag', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('article_attachments', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
}
|
||||||
|
};
|
||||||
35
database/migrations/2026_02_07_120006_create_pages_table.php
Normal file
35
database/migrations/2026_02_07_120006_create_pages_table.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('pages', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -90,6 +90,21 @@ class FinancialWorkflowPermissionsSeeder extends Seeder
|
|||||||
'delete_announcements' => '刪除公告',
|
'delete_announcements' => '刪除公告',
|
||||||
'publish_announcements' => '發布公告',
|
'publish_announcements' => '發布公告',
|
||||||
'manage_all_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) {
|
foreach ($permissions as $name => $description) {
|
||||||
@@ -131,6 +146,19 @@ class FinancialWorkflowPermissionsSeeder extends Seeder
|
|||||||
'delete_announcements',
|
'delete_announcements',
|
||||||
'publish_announcements',
|
'publish_announcements',
|
||||||
'manage_all_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' => '秘書長 - 協會行政負責人,負責初審所有財務申請',
|
'description' => '秘書長 - 協會行政負責人,負責初審所有財務申請',
|
||||||
],
|
],
|
||||||
@@ -227,6 +255,19 @@ class FinancialWorkflowPermissionsSeeder extends Seeder
|
|||||||
'delete_announcements',
|
'delete_announcements',
|
||||||
'publish_announcements',
|
'publish_announcements',
|
||||||
'manage_all_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' => '理事長 - 協會負責人,負責核決重大財務支出與會員繳費最終審核',
|
'description' => '理事長 - 協會負責人,負責核決重大財務支出與會員繳費最終審核',
|
||||||
],
|
],
|
||||||
@@ -244,6 +285,11 @@ class FinancialWorkflowPermissionsSeeder extends Seeder
|
|||||||
'edit_announcements',
|
'edit_announcements',
|
||||||
'delete_announcements',
|
'delete_announcements',
|
||||||
'publish_announcements',
|
'publish_announcements',
|
||||||
|
// 官網文章管理
|
||||||
|
'view_articles',
|
||||||
|
'create_articles',
|
||||||
|
'edit_articles',
|
||||||
|
'publish_articles',
|
||||||
],
|
],
|
||||||
'description' => '理事 - 理事會成員,協助監督協會運作與審核特定議案',
|
'description' => '理事 - 理事會成員,協助監督協會運作與審核特定議案',
|
||||||
],
|
],
|
||||||
@@ -267,6 +313,11 @@ class FinancialWorkflowPermissionsSeeder extends Seeder
|
|||||||
'edit_announcements',
|
'edit_announcements',
|
||||||
'delete_announcements',
|
'delete_announcements',
|
||||||
'publish_announcements',
|
'publish_announcements',
|
||||||
|
// 官網文章管理
|
||||||
|
'view_articles',
|
||||||
|
'create_articles',
|
||||||
|
'edit_articles',
|
||||||
|
'publish_articles',
|
||||||
],
|
],
|
||||||
'description' => '會員管理員 - 專責處理會員入會審核、資料維護與會籍管理',
|
'description' => '會員管理員 - 專責處理會員入會審核、資料維護與會籍管理',
|
||||||
],
|
],
|
||||||
|
|||||||
72
resources/views/admin/article-categories/create.blade.php
Normal file
72
resources/views/admin/article-categories/create.blade.php
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<x-app-layout>
|
||||||
|
<x-slot name="header">
|
||||||
|
<h2 class="text-xl font-semibold leading-tight text-gray-800 dark:text-gray-200">
|
||||||
|
新增文章類別
|
||||||
|
</h2>
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<div class="py-12">
|
||||||
|
<div class="mx-auto max-w-3xl sm:px-6 lg:px-8">
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg">
|
||||||
|
<form action="{{ route('admin.article-categories.store') }}" method="POST" class="p-6 space-y-6">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="name" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||||
|
類別名稱 <span class="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
|
<input type="text" name="name" id="name" value="{{ old('name') }}" required
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 @error('name') border-red-500 @enderror dark:bg-gray-700 dark:text-gray-100">
|
||||||
|
@error('name')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="slug" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||||
|
代碼 (URL slug)
|
||||||
|
</label>
|
||||||
|
<input type="text" name="slug" id="slug" value="{{ old('slug') }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 @error('slug') border-red-500 @enderror dark:bg-gray-700 dark:text-gray-100">
|
||||||
|
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400">留空則自動產生</p>
|
||||||
|
@error('slug')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="description" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||||
|
說明
|
||||||
|
</label>
|
||||||
|
<textarea name="description" id="description" rows="3"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 dark:bg-gray-700 dark:text-gray-100">{{ old('description') }}</textarea>
|
||||||
|
@error('description')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="sort_order" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||||
|
排序順序
|
||||||
|
</label>
|
||||||
|
<input type="number" name="sort_order" id="sort_order" value="{{ old('sort_order', 0) }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 dark:bg-gray-700 dark:text-gray-100">
|
||||||
|
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400">數字越小越前面</p>
|
||||||
|
@error('sort_order')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center justify-end space-x-4 pt-4">
|
||||||
|
<a href="{{ route('admin.article-categories.index') }}" class="rounded-md border border-gray-300 bg-white dark:bg-gray-700 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-600">
|
||||||
|
取消
|
||||||
|
</a>
|
||||||
|
<button type="submit" class="rounded-md border border-transparent bg-indigo-600 dark:bg-indigo-500 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 dark:hover:bg-indigo-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-600 focus:ring-offset-2 dark:focus:ring-offset-gray-800">
|
||||||
|
建立類別
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-app-layout>
|
||||||
73
resources/views/admin/article-categories/edit.blade.php
Normal file
73
resources/views/admin/article-categories/edit.blade.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<x-app-layout>
|
||||||
|
<x-slot name="header">
|
||||||
|
<h2 class="text-xl font-semibold leading-tight text-gray-800 dark:text-gray-200">
|
||||||
|
編輯文章類別
|
||||||
|
</h2>
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<div class="py-12">
|
||||||
|
<div class="mx-auto max-w-3xl sm:px-6 lg:px-8">
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg">
|
||||||
|
<form action="{{ route('admin.article-categories.update', $category) }}" method="POST" class="p-6 space-y-6">
|
||||||
|
@csrf
|
||||||
|
@method('PATCH')
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="name" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||||
|
類別名稱 <span class="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
|
<input type="text" name="name" id="name" value="{{ old('name', $category->name) }}" required
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 @error('name') border-red-500 @enderror dark:bg-gray-700 dark:text-gray-100">
|
||||||
|
@error('name')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="slug" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||||
|
代碼 (URL slug)
|
||||||
|
</label>
|
||||||
|
<input type="text" name="slug" id="slug" value="{{ old('slug', $category->slug) }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 @error('slug') border-red-500 @enderror dark:bg-gray-700 dark:text-gray-100">
|
||||||
|
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400">留空則自動產生</p>
|
||||||
|
@error('slug')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="description" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||||
|
說明
|
||||||
|
</label>
|
||||||
|
<textarea name="description" id="description" rows="3"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 dark:bg-gray-700 dark:text-gray-100">{{ old('description', $category->description) }}</textarea>
|
||||||
|
@error('description')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="sort_order" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||||
|
排序順序
|
||||||
|
</label>
|
||||||
|
<input type="number" name="sort_order" id="sort_order" value="{{ old('sort_order', $category->sort_order) }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 dark:bg-gray-700 dark:text-gray-100">
|
||||||
|
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400">數字越小越前面</p>
|
||||||
|
@error('sort_order')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center justify-end space-x-4 pt-4">
|
||||||
|
<a href="{{ route('admin.article-categories.index') }}" class="rounded-md border border-gray-300 bg-white dark:bg-gray-700 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-600">
|
||||||
|
取消
|
||||||
|
</a>
|
||||||
|
<button type="submit" class="rounded-md border border-transparent bg-indigo-600 dark:bg-indigo-500 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 dark:hover:bg-indigo-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-600 focus:ring-offset-2 dark:focus:ring-offset-gray-800">
|
||||||
|
更新類別
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-app-layout>
|
||||||
93
resources/views/admin/article-categories/index.blade.php
Normal file
93
resources/views/admin/article-categories/index.blade.php
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
<x-app-layout>
|
||||||
|
<x-slot name="header">
|
||||||
|
<h2 class="text-xl font-semibold leading-tight text-gray-800 dark:text-gray-200">
|
||||||
|
文章類別管理
|
||||||
|
</h2>
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<div class="py-12">
|
||||||
|
<div class="mx-auto max-w-7xl sm:px-6 lg:px-8 space-y-6">
|
||||||
|
@if (session('status'))
|
||||||
|
<div class="rounded-md bg-green-50 dark:bg-green-900/30 p-4">
|
||||||
|
<p class="text-sm font-medium text-green-800 dark:text-green-200">{{ session('status') }}</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (session('error'))
|
||||||
|
<div class="rounded-md bg-red-50 dark:bg-red-900/30 p-4">
|
||||||
|
<p class="text-sm font-medium text-red-800 dark:text-red-200">{{ session('error') }}</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="flex justify-between items-center">
|
||||||
|
<div>
|
||||||
|
<h3 class="text-lg font-medium text-gray-900 dark:text-gray-100">文章類別</h3>
|
||||||
|
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">管理文章分類,用於組織和篩選文章內容</p>
|
||||||
|
</div>
|
||||||
|
<a href="{{ route('admin.article-categories.create') }}" class="inline-flex items-center rounded-md border border-transparent bg-indigo-600 dark:bg-indigo-500 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 dark:hover:bg-indigo-600">
|
||||||
|
<svg class="-ml-1 mr-2 h-5 w-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
|
||||||
|
</svg>
|
||||||
|
新增類別
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg">
|
||||||
|
<div class="px-4 py-5 sm:p-6">
|
||||||
|
<div class="overflow-x-auto">
|
||||||
|
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
|
||||||
|
<thead class="bg-gray-50 dark:bg-gray-700">
|
||||||
|
<tr>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">名稱</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">代碼</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">文章數量</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">排序</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-right text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">操作</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="divide-y divide-gray-200 dark:divide-gray-700 bg-white dark:bg-gray-800">
|
||||||
|
@forelse ($categories as $category)
|
||||||
|
<tr class="hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
|
<div class="text-sm font-medium text-gray-900 dark:text-gray-100">{{ $category->name }}</div>
|
||||||
|
@if($category->description)
|
||||||
|
<div class="text-sm text-gray-500 dark:text-gray-400">{{ $category->description }}</div>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
<code class="px-2 py-1 bg-gray-100 rounded dark:bg-gray-700 dark:text-gray-200">{{ $category->slug }}</code>
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
{{ $category->articles_count ?? 0 }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
{{ $category->sort_order }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium space-x-2">
|
||||||
|
<a href="{{ route('admin.article-categories.edit', $category) }}" class="text-indigo-600 hover:text-indigo-900 dark:text-indigo-400 dark:hover:text-indigo-300">
|
||||||
|
編輯
|
||||||
|
</a>
|
||||||
|
<form action="{{ route('admin.article-categories.destroy', $category) }}" method="POST" class="inline" onsubmit="return confirm('確定要刪除此類別嗎?');">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<button type="submit" class="text-red-600 hover:text-red-900 dark:text-red-400 dark:hover:text-red-300">
|
||||||
|
刪除
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="5" class="px-6 py-4 text-center text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
尚無類別資料
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-app-layout>
|
||||||
67
resources/views/admin/article-tags/create.blade.php
Normal file
67
resources/views/admin/article-tags/create.blade.php
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<x-app-layout>
|
||||||
|
<x-slot name="header">
|
||||||
|
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
|
||||||
|
建立標籤
|
||||||
|
</h2>
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<div class="py-12">
|
||||||
|
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||||
|
|
||||||
|
@if (session('status'))
|
||||||
|
<div class="mb-4 px-4 py-3 bg-green-100 dark:bg-green-900 border border-green-400 dark:border-green-700 text-green-700 dark:text-green-300 rounded">
|
||||||
|
{{ session('status') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (session('error'))
|
||||||
|
<div class="mb-4 px-4 py-3 bg-red-100 dark:bg-red-900 border border-red-400 dark:border-red-700 text-red-700 dark:text-red-300 rounded">
|
||||||
|
{{ session('error') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
|
||||||
|
<div class="p-6 text-gray-900 dark:text-gray-100">
|
||||||
|
<form method="POST" action="{{ route('admin.article-tags.store') }}">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<div class="mb-4">
|
||||||
|
<label for="name" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||||
|
名稱
|
||||||
|
</label>
|
||||||
|
<input type="text" name="name" id="name" value="{{ old('name') }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
|
||||||
|
required>
|
||||||
|
@error('name')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-6">
|
||||||
|
<label for="slug" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||||
|
網址代碼
|
||||||
|
</label>
|
||||||
|
<input type="text" name="slug" id="slug" value="{{ old('slug') }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm">
|
||||||
|
@error('slug')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center gap-4">
|
||||||
|
<button type="submit"
|
||||||
|
class="inline-flex items-center px-4 py-2 bg-indigo-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-indigo-700 focus:bg-indigo-700 active:bg-indigo-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 transition ease-in-out duration-150">
|
||||||
|
儲存
|
||||||
|
</button>
|
||||||
|
<a href="{{ route('admin.article-tags.index') }}"
|
||||||
|
class="inline-flex items-center px-4 py-2 bg-gray-300 dark:bg-gray-700 border border-transparent rounded-md font-semibold text-xs text-gray-700 dark:text-gray-300 uppercase tracking-widest hover:bg-gray-400 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 transition ease-in-out duration-150">
|
||||||
|
取消
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-app-layout>
|
||||||
75
resources/views/admin/article-tags/edit.blade.php
Normal file
75
resources/views/admin/article-tags/edit.blade.php
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<x-app-layout>
|
||||||
|
<x-slot name="header">
|
||||||
|
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
|
||||||
|
編輯標籤
|
||||||
|
</h2>
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<div class="py-12">
|
||||||
|
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||||
|
|
||||||
|
@if (session('status'))
|
||||||
|
<div class="mb-4 px-4 py-3 bg-green-100 dark:bg-green-900 border border-green-400 dark:border-green-700 text-green-700 dark:text-green-300 rounded">
|
||||||
|
{{ session('status') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (session('error'))
|
||||||
|
<div class="mb-4 px-4 py-3 bg-red-100 dark:bg-red-900 border border-red-400 dark:border-red-700 text-red-700 dark:text-red-300 rounded">
|
||||||
|
{{ session('error') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
|
||||||
|
<div class="p-6 text-gray-900 dark:text-gray-100">
|
||||||
|
<form method="POST" action="{{ route('admin.article-tags.update', $tag) }}">
|
||||||
|
@csrf
|
||||||
|
@method('PATCH')
|
||||||
|
|
||||||
|
<div class="mb-4">
|
||||||
|
<label for="name" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||||
|
名稱
|
||||||
|
</label>
|
||||||
|
<input type="text" name="name" id="name" value="{{ old('name', $tag->name) }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
|
||||||
|
required>
|
||||||
|
@error('name')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-6">
|
||||||
|
<label for="slug" class="block text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||||
|
網址代碼
|
||||||
|
</label>
|
||||||
|
<input type="text" name="slug" id="slug" value="{{ old('slug', $tag->slug) }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm">
|
||||||
|
@error('slug')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center gap-4">
|
||||||
|
<button type="submit"
|
||||||
|
class="inline-flex items-center px-4 py-2 bg-indigo-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-indigo-700 focus:bg-indigo-700 active:bg-indigo-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 transition ease-in-out duration-150">
|
||||||
|
儲存
|
||||||
|
</button>
|
||||||
|
<a href="{{ route('admin.article-tags.index') }}"
|
||||||
|
class="inline-flex items-center px-4 py-2 bg-gray-300 dark:bg-gray-700 border border-transparent rounded-md font-semibold text-xs text-gray-700 dark:text-gray-300 uppercase tracking-widest hover:bg-gray-400 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 transition ease-in-out duration-150">
|
||||||
|
取消
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-6">
|
||||||
|
<a href="{{ route('admin.article-tags.index') }}"
|
||||||
|
class="text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200">
|
||||||
|
← 返回列表
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-app-layout>
|
||||||
90
resources/views/admin/article-tags/index.blade.php
Normal file
90
resources/views/admin/article-tags/index.blade.php
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
<x-app-layout>
|
||||||
|
<x-slot name="header">
|
||||||
|
<div class="flex justify-between items-center">
|
||||||
|
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
|
||||||
|
標籤管理
|
||||||
|
</h2>
|
||||||
|
<a href="{{ route('admin.article-tags.create') }}"
|
||||||
|
class="inline-flex items-center px-4 py-2 bg-indigo-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-indigo-700 focus:bg-indigo-700 active:bg-indigo-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 transition ease-in-out duration-150">
|
||||||
|
建立標籤
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<div class="py-12">
|
||||||
|
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||||
|
|
||||||
|
@if (session('status'))
|
||||||
|
<div class="mb-4 px-4 py-3 bg-green-100 dark:bg-green-900 border border-green-400 dark:border-green-700 text-green-700 dark:text-green-300 rounded">
|
||||||
|
{{ session('status') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (session('error'))
|
||||||
|
<div class="mb-4 px-4 py-3 bg-red-100 dark:bg-red-900 border border-red-400 dark:border-red-700 text-red-700 dark:text-red-300 rounded">
|
||||||
|
{{ session('error') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
|
||||||
|
<div class="p-6 text-gray-900 dark:text-gray-100">
|
||||||
|
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
|
||||||
|
<thead class="bg-gray-50 dark:bg-gray-900">
|
||||||
|
<tr>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">
|
||||||
|
名稱
|
||||||
|
</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">
|
||||||
|
網址代碼
|
||||||
|
</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">
|
||||||
|
文章數
|
||||||
|
</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">
|
||||||
|
操作
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700">
|
||||||
|
@forelse ($tags as $tag)
|
||||||
|
<tr>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-gray-100">
|
||||||
|
{{ $tag->name }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-300">
|
||||||
|
{{ $tag->slug }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-300">
|
||||||
|
{{ $tag->articles_count ?? 0 }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
||||||
|
<a href="{{ route('admin.article-tags.edit', $tag) }}"
|
||||||
|
class="text-indigo-600 dark:text-indigo-400 hover:text-indigo-900 dark:hover:text-indigo-300 mr-3">
|
||||||
|
編輯
|
||||||
|
</a>
|
||||||
|
<form action="{{ route('admin.article-tags.destroy', $tag) }}" method="POST" class="inline-block"
|
||||||
|
onsubmit="return confirm('確定要刪除此標籤嗎?')">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<button type="submit"
|
||||||
|
class="text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300">
|
||||||
|
刪除
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="4" class="px-6 py-4 text-center text-sm text-gray-500 dark:text-gray-300">
|
||||||
|
尚無標籤資料
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-app-layout>
|
||||||
242
resources/views/admin/articles/create.blade.php
Normal file
242
resources/views/admin/articles/create.blade.php
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
<x-app-layout>
|
||||||
|
<x-slot name="header">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<h2 class="text-xl font-semibold leading-tight text-gray-800 dark:text-gray-200">
|
||||||
|
建立文章
|
||||||
|
</h2>
|
||||||
|
<a href="{{ route('admin.articles.index') }}" class="inline-flex items-center rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-3 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
← 返回列表
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<div class="py-12">
|
||||||
|
<div class="mx-auto max-w-4xl sm:px-6 lg:px-8">
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg">
|
||||||
|
<form method="POST" action="{{ route('admin.articles.store') }}" enctype="multipart/form-data" class="space-y-6 p-6">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<!-- Title -->
|
||||||
|
<div>
|
||||||
|
<label for="title" class="block text-sm font-medium text-gray-700 dark:text-gray-300">標題 <span class="text-red-500">*</span></label>
|
||||||
|
<input type="text" name="title" id="title" value="{{ old('title') }}" required
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300"
|
||||||
|
placeholder="輸入文章標題">
|
||||||
|
@error('title')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Slug -->
|
||||||
|
<div>
|
||||||
|
<label for="slug" class="block text-sm font-medium text-gray-700 dark:text-gray-300">網址代碼(選填,自動產生)</label>
|
||||||
|
<input type="text" name="slug" id="slug" value="{{ old('slug') }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300"
|
||||||
|
placeholder="my-article-slug">
|
||||||
|
@error('slug')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Content Type -->
|
||||||
|
<div>
|
||||||
|
<label for="content_type" class="block text-sm font-medium text-gray-700 dark:text-gray-300">文章類型 <span class="text-red-500">*</span></label>
|
||||||
|
<select name="content_type" id="content_type" required
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
<option value="blog" {{ old('content_type') === 'blog' ? 'selected' : '' }}>部落格</option>
|
||||||
|
<option value="notice" {{ old('content_type') === 'notice' ? 'selected' : '' }}>公告</option>
|
||||||
|
<option value="document" {{ old('content_type') === 'document' ? 'selected' : '' }}>文件</option>
|
||||||
|
<option value="related_news" {{ old('content_type') === 'related_news' ? 'selected' : '' }}>相關新聞</option>
|
||||||
|
</select>
|
||||||
|
@error('content_type')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Summary -->
|
||||||
|
<div>
|
||||||
|
<label for="summary" class="block text-sm font-medium text-gray-700 dark:text-gray-300">摘要(選填)</label>
|
||||||
|
<textarea name="summary" id="summary" rows="3"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300"
|
||||||
|
placeholder="文章摘要,顯示於列表頁">{{ old('summary') }}</textarea>
|
||||||
|
@error('summary')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Content (Markdown Editor) -->
|
||||||
|
<div>
|
||||||
|
<label for="content" class="block text-sm font-medium text-gray-700 dark:text-gray-300">內容 <span class="text-red-500">*</span></label>
|
||||||
|
<textarea name="content" id="content" rows="15" required>{{ old('content') }}</textarea>
|
||||||
|
@error('content')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Featured Image -->
|
||||||
|
<div>
|
||||||
|
<label for="featured_image" class="block text-sm font-medium text-gray-700 dark:text-gray-300">精選圖片(選填)</label>
|
||||||
|
<input type="file" name="featured_image" id="featured_image" accept="image/*"
|
||||||
|
class="mt-1 block w-full text-sm text-gray-500 dark:text-gray-400 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-indigo-50 dark:file:bg-indigo-900/50 file:text-indigo-700 dark:file:text-indigo-300 hover:file:bg-indigo-100 dark:hover:file:bg-indigo-900">
|
||||||
|
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">最大 5MB,支援 JPG, PNG, GIF, WebP</p>
|
||||||
|
@error('featured_image')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Featured Image Alt -->
|
||||||
|
<div>
|
||||||
|
<label for="featured_image_alt" class="block text-sm font-medium text-gray-700 dark:text-gray-300">圖片替代文字(選填)</label>
|
||||||
|
<input type="text" name="featured_image_alt" id="featured_image_alt" value="{{ old('featured_image_alt') }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300"
|
||||||
|
placeholder="描述圖片內容(無障礙用途)">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Categories -->
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">分類(選填)</label>
|
||||||
|
<div class="mt-2 space-y-2">
|
||||||
|
@foreach($categories as $category)
|
||||||
|
<label class="inline-flex items-center mr-4">
|
||||||
|
<input type="checkbox" name="categories[]" value="{{ $category->id }}"
|
||||||
|
{{ in_array($category->id, old('categories', [])) ? 'checked' : '' }}
|
||||||
|
class="h-4 w-4 rounded border-gray-300 dark:border-gray-700 text-indigo-600 focus:ring-indigo-500 dark:bg-gray-900">
|
||||||
|
<span class="ml-2 text-sm text-gray-700 dark:text-gray-300">{{ $category->name }}</span>
|
||||||
|
</label>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Tags -->
|
||||||
|
<div>
|
||||||
|
<label for="tags_input" class="block text-sm font-medium text-gray-700 dark:text-gray-300">標籤(選填,逗號分隔)</label>
|
||||||
|
<input type="text" name="tags_input" id="tags_input" value="{{ old('tags_input') }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300"
|
||||||
|
placeholder="標籤1, 標籤2, 標籤3">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Author Name -->
|
||||||
|
<div>
|
||||||
|
<label for="author_name" class="block text-sm font-medium text-gray-700 dark:text-gray-300">作者名稱(選填)</label>
|
||||||
|
<input type="text" name="author_name" id="author_name" value="{{ old('author_name') }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300"
|
||||||
|
placeholder="顯示於文章的作者名稱">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Access Level -->
|
||||||
|
<div>
|
||||||
|
<label for="access_level" class="block text-sm font-medium text-gray-700 dark:text-gray-300">存取權限 <span class="text-red-500">*</span></label>
|
||||||
|
<select name="access_level" id="access_level" required
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
<option value="public" {{ old('access_level', 'public') === 'public' ? 'selected' : '' }}>公開(所有人可見)</option>
|
||||||
|
<option value="members" {{ old('access_level') === 'members' ? 'selected' : '' }}>會員(需付費會籍)</option>
|
||||||
|
<option value="board" {{ old('access_level') === 'board' ? 'selected' : '' }}>理事會(僅理事可見)</option>
|
||||||
|
<option value="admin" {{ old('access_level') === 'admin' ? 'selected' : '' }}>管理員(僅管理員可見)</option>
|
||||||
|
</select>
|
||||||
|
@error('access_level')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Published At -->
|
||||||
|
<div>
|
||||||
|
<label for="published_at" class="block text-sm font-medium text-gray-700 dark:text-gray-300">發布時間(選填,留空則立即發布)</label>
|
||||||
|
<input type="datetime-local" name="published_at" id="published_at" value="{{ old('published_at') }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">設定未來時間可排程發布</p>
|
||||||
|
@error('published_at')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Expires At -->
|
||||||
|
<div>
|
||||||
|
<label for="expires_at" class="block text-sm font-medium text-gray-700 dark:text-gray-300">過期時間(選填)</label>
|
||||||
|
<input type="datetime-local" name="expires_at" id="expires_at" value="{{ old('expires_at') }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
@error('expires_at')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Meta Description -->
|
||||||
|
<div>
|
||||||
|
<label for="meta_description" class="block text-sm font-medium text-gray-700 dark:text-gray-300">SEO 描述(選填)</label>
|
||||||
|
<textarea name="meta_description" id="meta_description" rows="2"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300"
|
||||||
|
placeholder="搜尋引擎描述">{{ old('meta_description') }}</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Is Pinned -->
|
||||||
|
<div class="flex items-center">
|
||||||
|
<input type="checkbox" name="is_pinned" id="is_pinned" value="1" {{ old('is_pinned') ? 'checked' : '' }}
|
||||||
|
class="h-4 w-4 rounded border-gray-300 dark:border-gray-700 text-indigo-600 focus:ring-indigo-500 dark:bg-gray-900">
|
||||||
|
<label for="is_pinned" class="ml-2 block text-sm text-gray-700 dark:text-gray-300">置頂此文章</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Display Order -->
|
||||||
|
<div id="display_order_container" style="display: none;">
|
||||||
|
<label for="display_order" class="block text-sm font-medium text-gray-700 dark:text-gray-300">顯示順序</label>
|
||||||
|
<input type="number" name="display_order" id="display_order" value="{{ old('display_order', 0) }}" min="0"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">數字越小越優先顯示</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Action Buttons -->
|
||||||
|
<div class="flex items-center justify-end space-x-3 border-t border-gray-200 dark:border-gray-700 pt-6">
|
||||||
|
<a href="{{ route('admin.articles.index') }}" class="rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
取消
|
||||||
|
</a>
|
||||||
|
<button type="submit" name="save_action" value="draft" class="rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
儲存為草稿
|
||||||
|
</button>
|
||||||
|
<button type="submit" name="save_action" value="publish" class="rounded-md border border-transparent bg-indigo-600 dark:bg-indigo-500 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 dark:hover:bg-indigo-600">
|
||||||
|
發布文章
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@push('styles')
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.css">
|
||||||
|
@endpush
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js"></script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
// EasyMDE Markdown Editor
|
||||||
|
const easyMDE = new EasyMDE({
|
||||||
|
element: document.getElementById('content'),
|
||||||
|
spellChecker: false,
|
||||||
|
autosave: {
|
||||||
|
enabled: true,
|
||||||
|
uniqueId: 'article-create',
|
||||||
|
delay: 10000,
|
||||||
|
},
|
||||||
|
placeholder: '使用 Markdown 撰寫文章內容...',
|
||||||
|
toolbar: [
|
||||||
|
'bold', 'italic', 'heading', '|',
|
||||||
|
'quote', 'unordered-list', 'ordered-list', '|',
|
||||||
|
'link', 'image', 'table', '|',
|
||||||
|
'preview', 'side-by-side', 'fullscreen', '|',
|
||||||
|
'guide'
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Pin toggle
|
||||||
|
const isPinnedCheckbox = document.getElementById('is_pinned');
|
||||||
|
const displayOrderContainer = document.getElementById('display_order_container');
|
||||||
|
|
||||||
|
function toggleDisplayOrder() {
|
||||||
|
displayOrderContainer.style.display = isPinnedCheckbox.checked ? 'block' : 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
isPinnedCheckbox.addEventListener('change', toggleDisplayOrder);
|
||||||
|
toggleDisplayOrder();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
</x-app-layout>
|
||||||
284
resources/views/admin/articles/edit.blade.php
Normal file
284
resources/views/admin/articles/edit.blade.php
Normal file
@@ -0,0 +1,284 @@
|
|||||||
|
<x-app-layout>
|
||||||
|
<x-slot name="header">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<h2 class="text-xl font-semibold leading-tight text-gray-800 dark:text-gray-200">
|
||||||
|
編輯文章
|
||||||
|
</h2>
|
||||||
|
<a href="{{ route('admin.articles.show', $article) }}" class="inline-flex items-center rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-3 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
← 返回查看
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<div class="py-12">
|
||||||
|
<div class="mx-auto max-w-4xl sm:px-6 lg:px-8 space-y-6">
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg">
|
||||||
|
<form method="POST" action="{{ route('admin.articles.update', $article) }}" enctype="multipart/form-data" class="space-y-6 p-6">
|
||||||
|
@csrf
|
||||||
|
@method('PATCH')
|
||||||
|
|
||||||
|
<!-- Title -->
|
||||||
|
<div>
|
||||||
|
<label for="title" class="block text-sm font-medium text-gray-700 dark:text-gray-300">標題 <span class="text-red-500">*</span></label>
|
||||||
|
<input type="text" name="title" id="title" value="{{ old('title', $article->title) }}" required
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
@error('title')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Slug -->
|
||||||
|
<div>
|
||||||
|
<label for="slug" class="block text-sm font-medium text-gray-700 dark:text-gray-300">網址代碼</label>
|
||||||
|
<input type="text" name="slug" id="slug" value="{{ old('slug', $article->slug) }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
@error('slug')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Content Type -->
|
||||||
|
<div>
|
||||||
|
<label for="content_type" class="block text-sm font-medium text-gray-700 dark:text-gray-300">文章類型 <span class="text-red-500">*</span></label>
|
||||||
|
<select name="content_type" id="content_type" required
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
<option value="blog" {{ old('content_type', $article->content_type) === 'blog' ? 'selected' : '' }}>部落格</option>
|
||||||
|
<option value="notice" {{ old('content_type', $article->content_type) === 'notice' ? 'selected' : '' }}>公告</option>
|
||||||
|
<option value="document" {{ old('content_type', $article->content_type) === 'document' ? 'selected' : '' }}>文件</option>
|
||||||
|
<option value="related_news" {{ old('content_type', $article->content_type) === 'related_news' ? 'selected' : '' }}>相關新聞</option>
|
||||||
|
</select>
|
||||||
|
@error('content_type')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Summary -->
|
||||||
|
<div>
|
||||||
|
<label for="summary" class="block text-sm font-medium text-gray-700 dark:text-gray-300">摘要(選填)</label>
|
||||||
|
<textarea name="summary" id="summary" rows="3"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">{{ old('summary', $article->summary) }}</textarea>
|
||||||
|
@error('summary')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Content (Markdown Editor) -->
|
||||||
|
<div>
|
||||||
|
<label for="content" class="block text-sm font-medium text-gray-700 dark:text-gray-300">內容 <span class="text-red-500">*</span></label>
|
||||||
|
<textarea name="content" id="content" rows="15" required>{{ old('content', $article->content) }}</textarea>
|
||||||
|
@error('content')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Featured Image -->
|
||||||
|
<div>
|
||||||
|
<label for="featured_image" class="block text-sm font-medium text-gray-700 dark:text-gray-300">精選圖片</label>
|
||||||
|
@if($article->featured_image_path)
|
||||||
|
<div class="mt-2 mb-2">
|
||||||
|
<img src="{{ $article->featured_image_url }}" alt="{{ $article->featured_image_alt }}" class="max-h-48 rounded-md">
|
||||||
|
<label class="mt-2 inline-flex items-center">
|
||||||
|
<input type="checkbox" name="remove_featured_image" value="1"
|
||||||
|
class="h-4 w-4 rounded border-gray-300 dark:border-gray-700 text-red-600 focus:ring-red-500 dark:bg-gray-900">
|
||||||
|
<span class="ml-2 text-sm text-red-600 dark:text-red-400">移除圖片</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
<input type="file" name="featured_image" id="featured_image" accept="image/*"
|
||||||
|
class="mt-1 block w-full text-sm text-gray-500 dark:text-gray-400 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-indigo-50 dark:file:bg-indigo-900/50 file:text-indigo-700 dark:file:text-indigo-300 hover:file:bg-indigo-100 dark:hover:file:bg-indigo-900">
|
||||||
|
@error('featured_image')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Featured Image Alt -->
|
||||||
|
<div>
|
||||||
|
<label for="featured_image_alt" class="block text-sm font-medium text-gray-700 dark:text-gray-300">圖片替代文字</label>
|
||||||
|
<input type="text" name="featured_image_alt" id="featured_image_alt" value="{{ old('featured_image_alt', $article->featured_image_alt) }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Categories -->
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">分類</label>
|
||||||
|
<div class="mt-2 space-y-2">
|
||||||
|
@foreach($categories as $category)
|
||||||
|
<label class="inline-flex items-center mr-4">
|
||||||
|
<input type="checkbox" name="categories[]" value="{{ $category->id }}"
|
||||||
|
{{ in_array($category->id, old('categories', $article->categories->pluck('id')->toArray())) ? 'checked' : '' }}
|
||||||
|
class="h-4 w-4 rounded border-gray-300 dark:border-gray-700 text-indigo-600 focus:ring-indigo-500 dark:bg-gray-900">
|
||||||
|
<span class="ml-2 text-sm text-gray-700 dark:text-gray-300">{{ $category->name }}</span>
|
||||||
|
</label>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Tags -->
|
||||||
|
<div>
|
||||||
|
<label for="tags_input" class="block text-sm font-medium text-gray-700 dark:text-gray-300">標籤(逗號分隔)</label>
|
||||||
|
<input type="text" name="tags_input" id="tags_input"
|
||||||
|
value="{{ old('tags_input', $article->tags->pluck('name')->implode(', ')) }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300"
|
||||||
|
placeholder="標籤1, 標籤2, 標籤3">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Author Name -->
|
||||||
|
<div>
|
||||||
|
<label for="author_name" class="block text-sm font-medium text-gray-700 dark:text-gray-300">作者名稱</label>
|
||||||
|
<input type="text" name="author_name" id="author_name" value="{{ old('author_name', $article->author_name) }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Access Level -->
|
||||||
|
<div>
|
||||||
|
<label for="access_level" class="block text-sm font-medium text-gray-700 dark:text-gray-300">存取權限 <span class="text-red-500">*</span></label>
|
||||||
|
<select name="access_level" id="access_level" required
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
<option value="public" {{ old('access_level', $article->access_level) === 'public' ? 'selected' : '' }}>公開</option>
|
||||||
|
<option value="members" {{ old('access_level', $article->access_level) === 'members' ? 'selected' : '' }}>會員</option>
|
||||||
|
<option value="board" {{ old('access_level', $article->access_level) === 'board' ? 'selected' : '' }}>理事會</option>
|
||||||
|
<option value="admin" {{ old('access_level', $article->access_level) === 'admin' ? 'selected' : '' }}>管理員</option>
|
||||||
|
</select>
|
||||||
|
@error('access_level')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Published At -->
|
||||||
|
<div>
|
||||||
|
<label for="published_at" class="block text-sm font-medium text-gray-700 dark:text-gray-300">發布時間</label>
|
||||||
|
<input type="datetime-local" name="published_at" id="published_at"
|
||||||
|
value="{{ old('published_at', $article->published_at?->format('Y-m-d\TH:i')) }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
@error('published_at')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Expires At -->
|
||||||
|
<div>
|
||||||
|
<label for="expires_at" class="block text-sm font-medium text-gray-700 dark:text-gray-300">過期時間</label>
|
||||||
|
<input type="datetime-local" name="expires_at" id="expires_at"
|
||||||
|
value="{{ old('expires_at', $article->expires_at?->format('Y-m-d\TH:i')) }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
@error('expires_at')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Meta Description -->
|
||||||
|
<div>
|
||||||
|
<label for="meta_description" class="block text-sm font-medium text-gray-700 dark:text-gray-300">SEO 描述</label>
|
||||||
|
<textarea name="meta_description" id="meta_description" rows="2"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">{{ old('meta_description', $article->meta_description) }}</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Is Pinned -->
|
||||||
|
<div class="flex items-center">
|
||||||
|
<input type="checkbox" name="is_pinned" id="is_pinned" value="1"
|
||||||
|
{{ old('is_pinned', $article->is_pinned) ? 'checked' : '' }}
|
||||||
|
class="h-4 w-4 rounded border-gray-300 dark:border-gray-700 text-indigo-600 focus:ring-indigo-500 dark:bg-gray-900">
|
||||||
|
<label for="is_pinned" class="ml-2 block text-sm text-gray-700 dark:text-gray-300">置頂此文章</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Display Order -->
|
||||||
|
<div id="display_order_container">
|
||||||
|
<label for="display_order" class="block text-sm font-medium text-gray-700 dark:text-gray-300">顯示順序</label>
|
||||||
|
<input type="number" name="display_order" id="display_order"
|
||||||
|
value="{{ old('display_order', $article->display_order) }}" min="0"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Action Buttons -->
|
||||||
|
<div class="flex items-center justify-end space-x-3 border-t border-gray-200 dark:border-gray-700 pt-6">
|
||||||
|
<a href="{{ route('admin.articles.show', $article) }}" class="rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
取消
|
||||||
|
</a>
|
||||||
|
<button type="submit" class="rounded-md border border-transparent bg-indigo-600 dark:bg-indigo-500 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 dark:hover:bg-indigo-600">
|
||||||
|
儲存變更
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Attachments Section -->
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg p-6">
|
||||||
|
<h4 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">附件管理</h4>
|
||||||
|
|
||||||
|
@if($article->attachments->count() > 0)
|
||||||
|
<div class="mb-4 space-y-2">
|
||||||
|
@foreach($article->attachments as $attachment)
|
||||||
|
<div class="flex items-center justify-between bg-gray-50 dark:bg-gray-700 rounded-md p-3">
|
||||||
|
<div>
|
||||||
|
<span class="text-sm font-medium text-gray-900 dark:text-gray-100">{{ $attachment->original_filename }}</span>
|
||||||
|
<span class="ml-2 text-xs text-gray-500 dark:text-gray-400">{{ number_format($attachment->file_size / 1024, 1) }} KB</span>
|
||||||
|
</div>
|
||||||
|
<form method="POST" action="{{ route('admin.articles.attachments.destroy', [$article, $attachment]) }}"
|
||||||
|
onsubmit="return confirm('確定要刪除此附件嗎?');">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<button type="submit" class="text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 text-sm">刪除</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<form method="POST" action="{{ route('admin.articles.attachments.store', $article) }}" enctype="multipart/form-data" class="flex items-end space-x-3">
|
||||||
|
@csrf
|
||||||
|
<div class="flex-1">
|
||||||
|
<label for="attachment" class="block text-sm font-medium text-gray-700 dark:text-gray-300">上傳附件</label>
|
||||||
|
<input type="file" name="attachment" id="attachment" required
|
||||||
|
class="mt-1 block w-full text-sm text-gray-500 dark:text-gray-400 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-indigo-50 dark:file:bg-indigo-900/50 file:text-indigo-700 dark:file:text-indigo-300 hover:file:bg-indigo-100 dark:hover:file:bg-indigo-900">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="text" name="description" placeholder="描述(選填)"
|
||||||
|
class="block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="rounded-md border border-transparent bg-indigo-600 dark:bg-indigo-500 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 dark:hover:bg-indigo-600">
|
||||||
|
上傳
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@push('styles')
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.css">
|
||||||
|
@endpush
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js"></script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
const easyMDE = new EasyMDE({
|
||||||
|
element: document.getElementById('content'),
|
||||||
|
spellChecker: false,
|
||||||
|
autosave: {
|
||||||
|
enabled: true,
|
||||||
|
uniqueId: 'article-edit-{{ $article->id }}',
|
||||||
|
delay: 10000,
|
||||||
|
},
|
||||||
|
placeholder: '使用 Markdown 撰寫文章內容...',
|
||||||
|
toolbar: [
|
||||||
|
'bold', 'italic', 'heading', '|',
|
||||||
|
'quote', 'unordered-list', 'ordered-list', '|',
|
||||||
|
'link', 'image', 'table', '|',
|
||||||
|
'preview', 'side-by-side', 'fullscreen', '|',
|
||||||
|
'guide'
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const isPinnedCheckbox = document.getElementById('is_pinned');
|
||||||
|
const displayOrderContainer = document.getElementById('display_order_container');
|
||||||
|
|
||||||
|
function toggleDisplayOrder() {
|
||||||
|
displayOrderContainer.style.display = isPinnedCheckbox.checked ? 'block' : 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
isPinnedCheckbox.addEventListener('change', toggleDisplayOrder);
|
||||||
|
toggleDisplayOrder();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
</x-app-layout>
|
||||||
184
resources/views/admin/articles/index.blade.php
Normal file
184
resources/views/admin/articles/index.blade.php
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
<x-app-layout>
|
||||||
|
<x-slot name="header">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<h2 class="text-xl font-semibold leading-tight text-gray-800 dark:text-gray-200">
|
||||||
|
官網文章管理
|
||||||
|
</h2>
|
||||||
|
<a href="{{ route('admin.articles.create') }}" class="inline-flex items-center rounded-md border border-transparent bg-indigo-600 dark:bg-indigo-500 px-3 py-2 text-sm font-medium text-white hover:bg-indigo-700 dark:hover:bg-indigo-600">
|
||||||
|
+ 建立文章
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<div class="py-12">
|
||||||
|
<div class="mx-auto max-w-7xl sm:px-6 lg:px-8 space-y-6">
|
||||||
|
@if (session('status'))
|
||||||
|
<div class="rounded-md bg-green-50 dark:bg-green-900/50 p-4">
|
||||||
|
<p class="text-sm font-medium text-green-800 dark:text-green-200">{{ session('status') }}</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (session('error'))
|
||||||
|
<div class="rounded-md bg-red-50 dark:bg-red-900/50 p-4">
|
||||||
|
<p class="text-sm font-medium text-red-800 dark:text-red-200">{{ session('error') }}</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Statistics -->
|
||||||
|
<div class="grid grid-cols-1 gap-4 md:grid-cols-5">
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg p-6">
|
||||||
|
<div class="text-sm font-medium text-gray-500 dark:text-gray-400">總計</div>
|
||||||
|
<div class="mt-2 text-3xl font-bold text-gray-900 dark:text-gray-100">{{ $stats['total'] }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg p-6">
|
||||||
|
<div class="text-sm font-medium text-gray-500 dark:text-gray-400">草稿</div>
|
||||||
|
<div class="mt-2 text-3xl font-bold text-gray-600 dark:text-gray-400">{{ $stats['draft'] }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg p-6">
|
||||||
|
<div class="text-sm font-medium text-gray-500 dark:text-gray-400">已發布</div>
|
||||||
|
<div class="mt-2 text-3xl font-bold text-green-600 dark:text-green-400">{{ $stats['published'] }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg p-6">
|
||||||
|
<div class="text-sm font-medium text-gray-500 dark:text-gray-400">已歸檔</div>
|
||||||
|
<div class="mt-2 text-3xl font-bold text-yellow-600 dark:text-yellow-400">{{ $stats['archived'] }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg p-6">
|
||||||
|
<div class="text-sm font-medium text-gray-500 dark:text-gray-400">置頂中</div>
|
||||||
|
<div class="mt-2 text-3xl font-bold text-blue-600 dark:text-blue-400">{{ $stats['pinned'] }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Search and Filter -->
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg p-6">
|
||||||
|
<form method="GET" action="{{ route('admin.articles.index') }}" class="space-y-4">
|
||||||
|
<div class="grid grid-cols-1 gap-4 md:grid-cols-4">
|
||||||
|
<div>
|
||||||
|
<label for="search" class="block text-sm font-medium text-gray-700 dark:text-gray-300">搜尋</label>
|
||||||
|
<input type="text" name="search" id="search" value="{{ request('search') }}" placeholder="標題、內容..."
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="status" class="block text-sm font-medium text-gray-700 dark:text-gray-300">狀態</label>
|
||||||
|
<select name="status" id="status" class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
<option value="">全部</option>
|
||||||
|
<option value="draft" {{ request('status') === 'draft' ? 'selected' : '' }}>草稿</option>
|
||||||
|
<option value="published" {{ request('status') === 'published' ? 'selected' : '' }}>已發布</option>
|
||||||
|
<option value="archived" {{ request('status') === 'archived' ? 'selected' : '' }}>已歸檔</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="content_type" class="block text-sm font-medium text-gray-700 dark:text-gray-300">類型</label>
|
||||||
|
<select name="content_type" id="content_type" class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
<option value="">全部</option>
|
||||||
|
<option value="blog" {{ request('content_type') === 'blog' ? 'selected' : '' }}>部落格</option>
|
||||||
|
<option value="notice" {{ request('content_type') === 'notice' ? 'selected' : '' }}>公告</option>
|
||||||
|
<option value="document" {{ request('content_type') === 'document' ? 'selected' : '' }}>文件</option>
|
||||||
|
<option value="related_news" {{ request('content_type') === 'related_news' ? 'selected' : '' }}>相關新聞</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="category" class="block text-sm font-medium text-gray-700 dark:text-gray-300">分類</label>
|
||||||
|
<select name="category" id="category" class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
<option value="">全部</option>
|
||||||
|
@foreach($categories as $category)
|
||||||
|
<option value="{{ $category->id }}" {{ request('category') == $category->id ? 'selected' : '' }}>{{ $category->name }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-end space-x-2">
|
||||||
|
<a href="{{ route('admin.articles.index') }}" class="rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
清除
|
||||||
|
</a>
|
||||||
|
<button type="submit" class="rounded-md border border-transparent bg-indigo-600 dark:bg-indigo-500 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 dark:hover:bg-indigo-600">
|
||||||
|
搜尋
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex justify-between items-center">
|
||||||
|
<p class="text-sm text-gray-600 dark:text-gray-400">共 {{ $articles->total() }} 篇文章</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Articles Table -->
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow overflow-hidden sm:rounded-lg">
|
||||||
|
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
|
||||||
|
<thead class="bg-gray-50 dark:bg-gray-700">
|
||||||
|
<tr>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">文章</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">類型</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">狀態</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">建立者</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">瀏覽</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">建立時間</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-right text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">操作</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700">
|
||||||
|
@forelse($articles as $article)
|
||||||
|
<tr class="hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
<td class="px-6 py-4">
|
||||||
|
<div class="flex items-center">
|
||||||
|
@if($article->is_pinned)
|
||||||
|
<span class="mr-2 text-blue-500" title="置頂文章">📌</span>
|
||||||
|
@endif
|
||||||
|
<div>
|
||||||
|
<div class="text-sm font-medium text-gray-900 dark:text-gray-100">
|
||||||
|
<a href="{{ route('admin.articles.show', $article) }}" class="hover:text-indigo-600 dark:hover:text-indigo-400">
|
||||||
|
{{ $article->title }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
{{ Str::limit(strip_tags($article->content), 60) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
{{ $article->getContentTypeLabel() }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
|
<span class="inline-flex rounded-full px-2 text-xs font-semibold leading-5
|
||||||
|
@if($article->status === 'draft') bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300
|
||||||
|
@elseif($article->status === 'published') bg-green-100 dark:bg-green-900/50 text-green-800 dark:text-green-300
|
||||||
|
@else bg-yellow-100 dark:bg-yellow-900/50 text-yellow-800 dark:text-yellow-300
|
||||||
|
@endif">
|
||||||
|
{{ $article->getStatusLabel() }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
{{ $article->creator->name ?? 'N/A' }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
{{ $article->view_count }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
{{ $article->created_at->format('Y-m-d H:i') }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium space-x-2">
|
||||||
|
<a href="{{ route('admin.articles.show', $article) }}" class="text-indigo-600 dark:text-indigo-400 hover:text-indigo-900 dark:hover:text-indigo-300">查看</a>
|
||||||
|
@if($article->canBeEditedBy(auth()->user()))
|
||||||
|
<a href="{{ route('admin.articles.edit', $article) }}" class="text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-300">編輯</a>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="7" class="px-6 py-12 text-center text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
沒有找到文章。<a href="{{ route('admin.articles.create') }}" class="text-indigo-600 dark:text-indigo-400 hover:underline">建立第一篇文章</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if($articles->hasPages())
|
||||||
|
<div class="bg-white dark:bg-gray-800 px-4 py-3 border-t border-gray-200 dark:border-gray-700 sm:px-6">
|
||||||
|
{{ $articles->links() }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-app-layout>
|
||||||
243
resources/views/admin/articles/show.blade.php
Normal file
243
resources/views/admin/articles/show.blade.php
Normal file
@@ -0,0 +1,243 @@
|
|||||||
|
<x-app-layout>
|
||||||
|
<x-slot name="header">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<h2 class="text-xl font-semibold leading-tight text-gray-800 dark:text-gray-200">
|
||||||
|
文章詳情
|
||||||
|
</h2>
|
||||||
|
<div class="flex items-center space-x-2">
|
||||||
|
<a href="{{ route('admin.articles.index') }}" class="inline-flex items-center rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-3 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
← 返回列表
|
||||||
|
</a>
|
||||||
|
@if($article->canBeEditedBy(auth()->user()))
|
||||||
|
<a href="{{ route('admin.articles.edit', $article) }}" class="inline-flex items-center rounded-md border border-transparent bg-indigo-600 dark:bg-indigo-500 px-3 py-2 text-sm font-medium text-white hover:bg-indigo-700 dark:hover:bg-indigo-600">
|
||||||
|
編輯文章
|
||||||
|
</a>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<div class="py-12">
|
||||||
|
<div class="mx-auto max-w-4xl sm:px-6 lg:px-8 space-y-6">
|
||||||
|
@if (session('status'))
|
||||||
|
<div class="rounded-md bg-green-50 dark:bg-green-900/50 p-4">
|
||||||
|
<p class="text-sm font-medium text-green-800 dark:text-green-200">{{ session('status') }}</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (session('error'))
|
||||||
|
<div class="rounded-md bg-red-50 dark:bg-red-900/50 p-4">
|
||||||
|
<p class="text-sm font-medium text-red-800 dark:text-red-200">{{ session('error') }}</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Article Content -->
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg p-6">
|
||||||
|
<div class="mb-6">
|
||||||
|
<div class="flex items-center justify-between mb-4">
|
||||||
|
<h3 class="text-2xl font-bold text-gray-900 dark:text-gray-100">
|
||||||
|
@if($article->is_pinned)
|
||||||
|
<span class="text-blue-500" title="置頂文章">📌</span>
|
||||||
|
@endif
|
||||||
|
{{ $article->title }}
|
||||||
|
</h3>
|
||||||
|
<div class="flex items-center space-x-2">
|
||||||
|
<span class="inline-flex rounded-full px-2 text-xs font-semibold leading-5 bg-blue-100 dark:bg-blue-900/50 text-blue-800 dark:text-blue-300">
|
||||||
|
{{ $article->getContentTypeLabel() }}
|
||||||
|
</span>
|
||||||
|
<span class="inline-flex rounded-full px-3 py-1 text-sm font-semibold
|
||||||
|
@if($article->status === 'draft') bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300
|
||||||
|
@elseif($article->status === 'published') bg-green-100 dark:bg-green-900/50 text-green-800 dark:text-green-300
|
||||||
|
@else bg-yellow-100 dark:bg-yellow-900/50 text-yellow-800 dark:text-yellow-300
|
||||||
|
@endif">
|
||||||
|
{{ $article->getStatusLabel() }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if($article->featured_image_path)
|
||||||
|
<div class="mb-4">
|
||||||
|
<img src="{{ $article->featured_image_url }}" alt="{{ $article->featured_image_alt ?? $article->title }}" class="max-h-64 rounded-md">
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if($article->summary)
|
||||||
|
<div class="mb-4 p-4 bg-gray-50 dark:bg-gray-700 rounded-md">
|
||||||
|
<p class="text-sm font-medium text-gray-500 dark:text-gray-400 mb-1">摘要</p>
|
||||||
|
<p class="text-gray-700 dark:text-gray-300">{{ $article->summary }}</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="prose dark:prose-invert max-w-none">
|
||||||
|
<div class="whitespace-pre-wrap text-gray-700 dark:text-gray-300">{{ $article->content }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if($article->categories->count() > 0)
|
||||||
|
<div class="flex flex-wrap gap-2 mt-4 pt-4 border-t border-gray-200 dark:border-gray-700">
|
||||||
|
<span class="text-sm text-gray-500 dark:text-gray-400">分類:</span>
|
||||||
|
@foreach($article->categories as $category)
|
||||||
|
<span class="inline-flex rounded-full bg-indigo-100 dark:bg-indigo-900/50 px-2 py-1 text-xs font-semibold text-indigo-800 dark:text-indigo-300">{{ $category->name }}</span>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if($article->tags->count() > 0)
|
||||||
|
<div class="flex flex-wrap gap-2 mt-2">
|
||||||
|
<span class="text-sm text-gray-500 dark:text-gray-400">標籤:</span>
|
||||||
|
@foreach($article->tags as $tag)
|
||||||
|
<span class="inline-flex rounded-full bg-gray-100 dark:bg-gray-700 px-2 py-1 text-xs font-semibold text-gray-600 dark:text-gray-300">{{ $tag->name }}</span>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Attachments -->
|
||||||
|
@if($article->attachments->count() > 0)
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg p-6">
|
||||||
|
<h4 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">附件</h4>
|
||||||
|
<div class="space-y-2">
|
||||||
|
@foreach($article->attachments as $attachment)
|
||||||
|
<div class="flex items-center justify-between bg-gray-50 dark:bg-gray-700 rounded-md p-3">
|
||||||
|
<div>
|
||||||
|
<span class="text-sm font-medium text-gray-900 dark:text-gray-100">{{ $attachment->original_filename }}</span>
|
||||||
|
<span class="ml-2 text-xs text-gray-500 dark:text-gray-400">{{ number_format($attachment->file_size / 1024, 1) }} KB</span>
|
||||||
|
@if($attachment->description)
|
||||||
|
<span class="ml-2 text-xs text-gray-500 dark:text-gray-400">- {{ $attachment->description }}</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<span class="text-xs text-gray-500 dark:text-gray-400">下載 {{ $attachment->download_count }} 次</span>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Metadata -->
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg p-6">
|
||||||
|
<h4 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">文章資訊</h4>
|
||||||
|
<dl class="grid grid-cols-1 gap-x-4 gap-y-6 sm:grid-cols-2">
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">存取權限</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ $article->getAccessLevelLabel() }}</dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">瀏覽次數</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ $article->view_count }}</dd>
|
||||||
|
</div>
|
||||||
|
@if($article->author_name)
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">作者</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ $article->author_name }}</dd>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">建立者</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ $article->creator->name ?? 'N/A' }}</dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">網址代碼</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100 font-mono">{{ $article->slug }}</dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">建立時間</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ $article->created_at->format('Y-m-d H:i:s') }}</dd>
|
||||||
|
</div>
|
||||||
|
@if($article->published_at)
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">發布時間</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">
|
||||||
|
{{ $article->published_at->format('Y-m-d H:i:s') }}
|
||||||
|
@if($article->isScheduled())
|
||||||
|
<span class="ml-2 inline-flex rounded-full bg-blue-100 dark:bg-blue-900/50 px-2 py-1 text-xs font-semibold text-blue-800 dark:text-blue-300">排程中</span>
|
||||||
|
@endif
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if($article->expires_at)
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">過期時間</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">
|
||||||
|
{{ $article->expires_at->format('Y-m-d H:i:s') }}
|
||||||
|
@if($article->isExpired())
|
||||||
|
<span class="ml-2 inline-flex rounded-full bg-red-100 dark:bg-red-900/50 px-2 py-1 text-xs font-semibold text-red-800 dark:text-red-300">已過期</span>
|
||||||
|
@endif
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if($article->lastUpdatedBy)
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">最後更新者</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ $article->lastUpdatedBy->name }}</dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">最後更新時間</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ $article->updated_at->format('Y-m-d H:i:s') }}</dd>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if($article->meta_description)
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">SEO 描述</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ $article->meta_description }}</dd>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Actions -->
|
||||||
|
@if($article->canBeEditedBy(auth()->user()))
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg p-6">
|
||||||
|
<h4 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">操作</h4>
|
||||||
|
<div class="flex flex-wrap gap-3">
|
||||||
|
@if($article->isDraft() && auth()->user()->can('publish_articles'))
|
||||||
|
<form method="POST" action="{{ route('admin.articles.publish', $article) }}">
|
||||||
|
@csrf
|
||||||
|
<button type="submit" class="inline-flex items-center rounded-md border border-transparent bg-green-600 dark:bg-green-500 px-4 py-2 text-sm font-medium text-white hover:bg-green-700 dark:hover:bg-green-600">
|
||||||
|
發布文章
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if($article->isPublished() && auth()->user()->can('publish_articles'))
|
||||||
|
<form method="POST" action="{{ route('admin.articles.archive', $article) }}">
|
||||||
|
@csrf
|
||||||
|
<button type="submit" class="inline-flex items-center rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
歸檔文章
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if(!$article->is_pinned && auth()->user()->can('edit_articles'))
|
||||||
|
<form method="POST" action="{{ route('admin.articles.pin', $article) }}">
|
||||||
|
@csrf
|
||||||
|
<button type="submit" class="inline-flex items-center rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
📌 置頂文章
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if($article->is_pinned && auth()->user()->can('edit_articles'))
|
||||||
|
<form method="POST" action="{{ route('admin.articles.unpin', $article) }}">
|
||||||
|
@csrf
|
||||||
|
<button type="submit" class="inline-flex items-center rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
取消置頂
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if(auth()->user()->can('delete_articles'))
|
||||||
|
<form method="POST" action="{{ route('admin.articles.destroy', $article) }}"
|
||||||
|
onsubmit="return confirm('確定要刪除此文章嗎?');">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<button type="submit" class="inline-flex items-center rounded-md border border-transparent bg-red-600 dark:bg-red-500 px-4 py-2 text-sm font-medium text-white hover:bg-red-700 dark:hover:bg-red-600">
|
||||||
|
刪除文章
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-app-layout>
|
||||||
131
resources/views/admin/pages/create.blade.php
Normal file
131
resources/views/admin/pages/create.blade.php
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
<x-app-layout>
|
||||||
|
<x-slot name="header">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<h2 class="text-xl font-semibold leading-tight text-gray-800 dark:text-gray-200">
|
||||||
|
建立頁面
|
||||||
|
</h2>
|
||||||
|
<a href="{{ route('admin.pages.index') }}" class="inline-flex items-center rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-3 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
← 返回列表
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<div class="py-12">
|
||||||
|
<div class="mx-auto max-w-4xl sm:px-6 lg:px-8">
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg">
|
||||||
|
<form method="POST" action="{{ route('admin.pages.store') }}" class="space-y-6 p-6">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<!-- Title -->
|
||||||
|
<div>
|
||||||
|
<label for="title" class="block text-sm font-medium text-gray-700 dark:text-gray-300">標題 <span class="text-red-500">*</span></label>
|
||||||
|
<input type="text" name="title" id="title" value="{{ old('title') }}" required
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300"
|
||||||
|
placeholder="輸入頁面標題">
|
||||||
|
@error('title')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Slug -->
|
||||||
|
<div>
|
||||||
|
<label for="slug" class="block text-sm font-medium text-gray-700 dark:text-gray-300">網址代碼(選填,自動產生)</label>
|
||||||
|
<input type="text" name="slug" id="slug" value="{{ old('slug') }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300"
|
||||||
|
placeholder="about-us">
|
||||||
|
@error('slug')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Parent Page -->
|
||||||
|
<div>
|
||||||
|
<label for="parent_id" class="block text-sm font-medium text-gray-700 dark:text-gray-300">上層頁面(選填)</label>
|
||||||
|
<select name="parent_id" id="parent_id"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
<option value="">無(頂層頁面)</option>
|
||||||
|
@foreach($parentPages as $parentPage)
|
||||||
|
<option value="{{ $parentPage->id }}" {{ old('parent_id') == $parentPage->id ? 'selected' : '' }}>{{ $parentPage->title }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Content (Markdown Editor) -->
|
||||||
|
<div>
|
||||||
|
<label for="content" class="block text-sm font-medium text-gray-700 dark:text-gray-300">內容 <span class="text-red-500">*</span></label>
|
||||||
|
<textarea name="content" id="content" rows="15" required>{{ old('content') }}</textarea>
|
||||||
|
@error('content')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Template -->
|
||||||
|
<div>
|
||||||
|
<label for="template" class="block text-sm font-medium text-gray-700 dark:text-gray-300">模板(選填)</label>
|
||||||
|
<input type="text" name="template" id="template" value="{{ old('template') }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300"
|
||||||
|
placeholder="例如:homepage, about, contact">
|
||||||
|
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">用於前端顯示不同版面配置</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Sort Order -->
|
||||||
|
<div>
|
||||||
|
<label for="sort_order" class="block text-sm font-medium text-gray-700 dark:text-gray-300">排序</label>
|
||||||
|
<input type="number" name="sort_order" id="sort_order" value="{{ old('sort_order', 0) }}" min="0"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Meta Description -->
|
||||||
|
<div>
|
||||||
|
<label for="meta_description" class="block text-sm font-medium text-gray-700 dark:text-gray-300">SEO 描述(選填)</label>
|
||||||
|
<textarea name="meta_description" id="meta_description" rows="2"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300"
|
||||||
|
placeholder="搜尋引擎描述">{{ old('meta_description') }}</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Action Buttons -->
|
||||||
|
<div class="flex items-center justify-end space-x-3 border-t border-gray-200 dark:border-gray-700 pt-6">
|
||||||
|
<a href="{{ route('admin.pages.index') }}" class="rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
取消
|
||||||
|
</a>
|
||||||
|
<button type="submit" name="status" value="draft" class="rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
儲存為草稿
|
||||||
|
</button>
|
||||||
|
<button type="submit" name="status" value="published" class="rounded-md border border-transparent bg-indigo-600 dark:bg-indigo-500 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 dark:hover:bg-indigo-600">
|
||||||
|
發布頁面
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@push('styles')
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.css">
|
||||||
|
@endpush
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js"></script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
new EasyMDE({
|
||||||
|
element: document.getElementById('content'),
|
||||||
|
spellChecker: false,
|
||||||
|
autosave: {
|
||||||
|
enabled: true,
|
||||||
|
uniqueId: 'page-create',
|
||||||
|
delay: 10000,
|
||||||
|
},
|
||||||
|
placeholder: '使用 Markdown 撰寫頁面內容...',
|
||||||
|
toolbar: [
|
||||||
|
'bold', 'italic', 'heading', '|',
|
||||||
|
'quote', 'unordered-list', 'ordered-list', '|',
|
||||||
|
'link', 'image', 'table', '|',
|
||||||
|
'preview', 'side-by-side', 'fullscreen', '|',
|
||||||
|
'guide'
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
</x-app-layout>
|
||||||
135
resources/views/admin/pages/edit.blade.php
Normal file
135
resources/views/admin/pages/edit.blade.php
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
<x-app-layout>
|
||||||
|
<x-slot name="header">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<h2 class="text-xl font-semibold leading-tight text-gray-800 dark:text-gray-200">
|
||||||
|
編輯頁面
|
||||||
|
</h2>
|
||||||
|
<a href="{{ route('admin.pages.show', $page) }}" class="inline-flex items-center rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-3 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
← 返回查看
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<div class="py-12">
|
||||||
|
<div class="mx-auto max-w-4xl sm:px-6 lg:px-8">
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg">
|
||||||
|
<form method="POST" action="{{ route('admin.pages.update', $page) }}" class="space-y-6 p-6">
|
||||||
|
@csrf
|
||||||
|
@method('PATCH')
|
||||||
|
|
||||||
|
<!-- Title -->
|
||||||
|
<div>
|
||||||
|
<label for="title" class="block text-sm font-medium text-gray-700 dark:text-gray-300">標題 <span class="text-red-500">*</span></label>
|
||||||
|
<input type="text" name="title" id="title" value="{{ old('title', $page->title) }}" required
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
@error('title')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Slug -->
|
||||||
|
<div>
|
||||||
|
<label for="slug" class="block text-sm font-medium text-gray-700 dark:text-gray-300">網址代碼</label>
|
||||||
|
<input type="text" name="slug" id="slug" value="{{ old('slug', $page->slug) }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
@error('slug')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Parent Page -->
|
||||||
|
<div>
|
||||||
|
<label for="parent_id" class="block text-sm font-medium text-gray-700 dark:text-gray-300">上層頁面</label>
|
||||||
|
<select name="parent_id" id="parent_id"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
<option value="">無(頂層頁面)</option>
|
||||||
|
@foreach($parentPages as $parentPage)
|
||||||
|
<option value="{{ $parentPage->id }}" {{ old('parent_id', $page->parent_id) == $parentPage->id ? 'selected' : '' }}>{{ $parentPage->title }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Content (Markdown Editor) -->
|
||||||
|
<div>
|
||||||
|
<label for="content" class="block text-sm font-medium text-gray-700 dark:text-gray-300">內容 <span class="text-red-500">*</span></label>
|
||||||
|
<textarea name="content" id="content" rows="15" required>{{ old('content', $page->content) }}</textarea>
|
||||||
|
@error('content')
|
||||||
|
<p class="mt-1 text-sm text-red-600 dark:text-red-400">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Template -->
|
||||||
|
<div>
|
||||||
|
<label for="template" class="block text-sm font-medium text-gray-700 dark:text-gray-300">模板</label>
|
||||||
|
<input type="text" name="template" id="template" value="{{ old('template', $page->template) }}"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300"
|
||||||
|
placeholder="例如:homepage, about, contact">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Status -->
|
||||||
|
<div>
|
||||||
|
<label for="status" class="block text-sm font-medium text-gray-700 dark:text-gray-300">狀態</label>
|
||||||
|
<select name="status" id="status"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
<option value="draft" {{ old('status', $page->status) === 'draft' ? 'selected' : '' }}>草稿</option>
|
||||||
|
<option value="published" {{ old('status', $page->status) === 'published' ? 'selected' : '' }}>已發布</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Sort Order -->
|
||||||
|
<div>
|
||||||
|
<label for="sort_order" class="block text-sm font-medium text-gray-700 dark:text-gray-300">排序</label>
|
||||||
|
<input type="number" name="sort_order" id="sort_order" value="{{ old('sort_order', $page->sort_order) }}" min="0"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Meta Description -->
|
||||||
|
<div>
|
||||||
|
<label for="meta_description" class="block text-sm font-medium text-gray-700 dark:text-gray-300">SEO 描述</label>
|
||||||
|
<textarea name="meta_description" id="meta_description" rows="2"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 sm:text-sm dark:bg-gray-900 dark:text-gray-300">{{ old('meta_description', $page->meta_description) }}</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Action Buttons -->
|
||||||
|
<div class="flex items-center justify-end space-x-3 border-t border-gray-200 dark:border-gray-700 pt-6">
|
||||||
|
<a href="{{ route('admin.pages.show', $page) }}" class="rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
取消
|
||||||
|
</a>
|
||||||
|
<button type="submit" class="rounded-md border border-transparent bg-indigo-600 dark:bg-indigo-500 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 dark:hover:bg-indigo-600">
|
||||||
|
儲存變更
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@push('styles')
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.css">
|
||||||
|
@endpush
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js"></script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
new EasyMDE({
|
||||||
|
element: document.getElementById('content'),
|
||||||
|
spellChecker: false,
|
||||||
|
autosave: {
|
||||||
|
enabled: true,
|
||||||
|
uniqueId: 'page-edit-{{ $page->id }}',
|
||||||
|
delay: 10000,
|
||||||
|
},
|
||||||
|
placeholder: '使用 Markdown 撰寫頁面內容...',
|
||||||
|
toolbar: [
|
||||||
|
'bold', 'italic', 'heading', '|',
|
||||||
|
'quote', 'unordered-list', 'ordered-list', '|',
|
||||||
|
'link', 'image', 'table', '|',
|
||||||
|
'preview', 'side-by-side', 'fullscreen', '|',
|
||||||
|
'guide'
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
</x-app-layout>
|
||||||
120
resources/views/admin/pages/index.blade.php
Normal file
120
resources/views/admin/pages/index.blade.php
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<x-app-layout>
|
||||||
|
<x-slot name="header">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<h2 class="text-xl font-semibold leading-tight text-gray-800 dark:text-gray-200">
|
||||||
|
官網頁面管理
|
||||||
|
</h2>
|
||||||
|
<a href="{{ route('admin.pages.create') }}" class="inline-flex items-center rounded-md border border-transparent bg-indigo-600 dark:bg-indigo-500 px-3 py-2 text-sm font-medium text-white hover:bg-indigo-700 dark:hover:bg-indigo-600">
|
||||||
|
+ 建立頁面
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<div class="py-12">
|
||||||
|
<div class="mx-auto max-w-7xl sm:px-6 lg:px-8 space-y-6">
|
||||||
|
@if (session('status'))
|
||||||
|
<div class="rounded-md bg-green-50 dark:bg-green-900/50 p-4">
|
||||||
|
<p class="text-sm font-medium text-green-800 dark:text-green-200">{{ session('status') }}</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (session('error'))
|
||||||
|
<div class="rounded-md bg-red-50 dark:bg-red-900/50 p-4">
|
||||||
|
<p class="text-sm font-medium text-red-800 dark:text-red-200">{{ session('error') }}</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow overflow-hidden sm:rounded-lg">
|
||||||
|
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
|
||||||
|
<thead class="bg-gray-50 dark:bg-gray-700">
|
||||||
|
<tr>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">頁面</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">網址代碼</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">狀態</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">排序</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">建立者</th>
|
||||||
|
<th scope="col" class="px-6 py-3 text-right text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-300">操作</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700">
|
||||||
|
@forelse($pages as $page)
|
||||||
|
<tr class="hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
|
<div class="text-sm font-medium text-gray-900 dark:text-gray-100">
|
||||||
|
<a href="{{ route('admin.pages.show', $page) }}" class="hover:text-indigo-600 dark:hover:text-indigo-400">
|
||||||
|
{{ $page->title }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
@if($page->template)
|
||||||
|
<div class="text-xs text-gray-500 dark:text-gray-400">模板:{{ $page->template }}</div>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400 font-mono">
|
||||||
|
{{ $page->slug }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
|
<span class="inline-flex rounded-full px-2 text-xs font-semibold leading-5
|
||||||
|
@if($page->status === 'draft') bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300
|
||||||
|
@else bg-green-100 dark:bg-green-900/50 text-green-800 dark:text-green-300
|
||||||
|
@endif">
|
||||||
|
{{ $page->getStatusLabel() }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
{{ $page->sort_order }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
{{ $page->creator->name ?? 'N/A' }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium space-x-2">
|
||||||
|
<a href="{{ route('admin.pages.show', $page) }}" class="text-indigo-600 dark:text-indigo-400 hover:text-indigo-900 dark:hover:text-indigo-300">查看</a>
|
||||||
|
<a href="{{ route('admin.pages.edit', $page) }}" class="text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-300">編輯</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{-- Child pages --}}
|
||||||
|
@foreach($page->children as $child)
|
||||||
|
<tr class="hover:bg-gray-50 dark:hover:bg-gray-700 bg-gray-50/50 dark:bg-gray-800/50">
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap pl-12">
|
||||||
|
<div class="text-sm font-medium text-gray-900 dark:text-gray-100">
|
||||||
|
<span class="text-gray-400 dark:text-gray-500 mr-1">└</span>
|
||||||
|
<a href="{{ route('admin.pages.show', $child) }}" class="hover:text-indigo-600 dark:hover:text-indigo-400">
|
||||||
|
{{ $child->title }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400 font-mono">
|
||||||
|
{{ $child->slug }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap">
|
||||||
|
<span class="inline-flex rounded-full px-2 text-xs font-semibold leading-5
|
||||||
|
@if($child->status === 'draft') bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300
|
||||||
|
@else bg-green-100 dark:bg-green-900/50 text-green-800 dark:text-green-300
|
||||||
|
@endif">
|
||||||
|
{{ $child->getStatusLabel() }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
{{ $child->sort_order }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
{{ $child->creator->name ?? 'N/A' }}
|
||||||
|
</td>
|
||||||
|
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium space-x-2">
|
||||||
|
<a href="{{ route('admin.pages.show', $child) }}" class="text-indigo-600 dark:text-indigo-400 hover:text-indigo-900 dark:hover:text-indigo-300">查看</a>
|
||||||
|
<a href="{{ route('admin.pages.edit', $child) }}" class="text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-300">編輯</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="6" class="px-6 py-12 text-center text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
沒有找到頁面。<a href="{{ route('admin.pages.create') }}" class="text-indigo-600 dark:text-indigo-400 hover:underline">建立第一個頁面</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-app-layout>
|
||||||
155
resources/views/admin/pages/show.blade.php
Normal file
155
resources/views/admin/pages/show.blade.php
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
<x-app-layout>
|
||||||
|
<x-slot name="header">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<h2 class="text-xl font-semibold leading-tight text-gray-800 dark:text-gray-200">
|
||||||
|
頁面詳情
|
||||||
|
</h2>
|
||||||
|
<div class="flex items-center space-x-2">
|
||||||
|
<a href="{{ route('admin.pages.index') }}" class="inline-flex items-center rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-3 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||||
|
← 返回列表
|
||||||
|
</a>
|
||||||
|
<a href="{{ route('admin.pages.edit', $page) }}" class="inline-flex items-center rounded-md border border-transparent bg-indigo-600 dark:bg-indigo-500 px-3 py-2 text-sm font-medium text-white hover:bg-indigo-700 dark:hover:bg-indigo-600">
|
||||||
|
編輯頁面
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<div class="py-12">
|
||||||
|
<div class="mx-auto max-w-4xl sm:px-6 lg:px-8 space-y-6">
|
||||||
|
@if (session('status'))
|
||||||
|
<div class="rounded-md bg-green-50 dark:bg-green-900/50 p-4">
|
||||||
|
<p class="text-sm font-medium text-green-800 dark:text-green-200">{{ session('status') }}</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (session('error'))
|
||||||
|
<div class="rounded-md bg-red-50 dark:bg-red-900/50 p-4">
|
||||||
|
<p class="text-sm font-medium text-red-800 dark:text-red-200">{{ session('error') }}</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Page Content -->
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg p-6">
|
||||||
|
<div class="mb-6">
|
||||||
|
<div class="flex items-center justify-between mb-4">
|
||||||
|
<h3 class="text-2xl font-bold text-gray-900 dark:text-gray-100">
|
||||||
|
{{ $page->title }}
|
||||||
|
</h3>
|
||||||
|
<span class="inline-flex rounded-full px-3 py-1 text-sm font-semibold
|
||||||
|
@if($page->status === 'draft') bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300
|
||||||
|
@else bg-green-100 dark:bg-green-900/50 text-green-800 dark:text-green-300
|
||||||
|
@endif">
|
||||||
|
{{ $page->getStatusLabel() }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="prose dark:prose-invert max-w-none">
|
||||||
|
<div class="whitespace-pre-wrap text-gray-700 dark:text-gray-300">{{ $page->content }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Child Pages -->
|
||||||
|
@if($page->children->count() > 0)
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg p-6">
|
||||||
|
<h4 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">子頁面</h4>
|
||||||
|
<div class="space-y-2">
|
||||||
|
@foreach($page->children as $child)
|
||||||
|
<div class="flex items-center justify-between bg-gray-50 dark:bg-gray-700 rounded-md p-3">
|
||||||
|
<a href="{{ route('admin.pages.show', $child) }}" class="text-sm font-medium text-indigo-600 dark:text-indigo-400 hover:text-indigo-800 dark:hover:text-indigo-300">{{ $child->title }}</a>
|
||||||
|
<span class="inline-flex rounded-full px-2 text-xs font-semibold leading-5
|
||||||
|
@if($child->status === 'draft') bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300
|
||||||
|
@else bg-green-100 dark:bg-green-900/50 text-green-800 dark:text-green-300
|
||||||
|
@endif">
|
||||||
|
{{ $child->getStatusLabel() }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Metadata -->
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg p-6">
|
||||||
|
<h4 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">頁面資訊</h4>
|
||||||
|
<dl class="grid grid-cols-1 gap-x-4 gap-y-6 sm:grid-cols-2">
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">網址代碼</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100 font-mono">{{ $page->slug }}</dd>
|
||||||
|
</div>
|
||||||
|
@if($page->template)
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">模板</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ $page->template }}</dd>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if($page->parent)
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">上層頁面</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">
|
||||||
|
<a href="{{ route('admin.pages.show', $page->parent) }}" class="text-indigo-600 dark:text-indigo-400 hover:underline">{{ $page->parent->title }}</a>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">排序</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ $page->sort_order }}</dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">建立者</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ $page->creator->name ?? 'N/A' }}</dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">建立時間</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ $page->created_at->format('Y-m-d H:i:s') }}</dd>
|
||||||
|
</div>
|
||||||
|
@if($page->published_at)
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">發布時間</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ $page->published_at->format('Y-m-d H:i:s') }}</dd>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if($page->lastUpdatedBy)
|
||||||
|
<div>
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">最後更新者</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ $page->lastUpdatedBy->name }}</dd>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if($page->meta_description)
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">SEO 描述</dt>
|
||||||
|
<dd class="mt-1 text-sm text-gray-900 dark:text-gray-100">{{ $page->meta_description }}</dd>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Actions -->
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow sm:rounded-lg p-6">
|
||||||
|
<h4 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">操作</h4>
|
||||||
|
<div class="flex flex-wrap gap-3">
|
||||||
|
@if($page->isDraft() && auth()->user()->can('publish_pages'))
|
||||||
|
<form method="POST" action="{{ route('admin.pages.publish', $page) }}">
|
||||||
|
@csrf
|
||||||
|
<button type="submit" class="inline-flex items-center rounded-md border border-transparent bg-green-600 dark:bg-green-500 px-4 py-2 text-sm font-medium text-white hover:bg-green-700 dark:hover:bg-green-600">
|
||||||
|
發布頁面
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if(auth()->user()->can('delete_pages'))
|
||||||
|
<form method="POST" action="{{ route('admin.pages.destroy', $page) }}"
|
||||||
|
onsubmit="return confirm('確定要刪除此頁面嗎?');">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<button type="submit" class="inline-flex items-center rounded-md border border-transparent bg-red-600 dark:bg-red-500 px-4 py-2 text-sm font-medium text-white hover:bg-red-700 dark:hover:bg-red-600">
|
||||||
|
刪除頁面
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-app-layout>
|
||||||
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
<!-- Scripts -->
|
<!-- Scripts -->
|
||||||
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
||||||
|
|
||||||
|
@stack('styles')
|
||||||
</head>
|
</head>
|
||||||
<body class="font-sans antialiased bg-gray-50 text-slate-900 transition-colors duration-300 dark:bg-slate-900 dark:text-slate-100">
|
<body class="font-sans antialiased bg-gray-50 text-slate-900 transition-colors duration-300 dark:bg-slate-900 dark:text-slate-100">
|
||||||
<a href="#main-content" class="sr-only focus:not-sr-only focus:absolute focus:z-50 focus:p-4 focus:bg-white focus:text-black focus:outline-none focus:ring-2 focus:ring-indigo-500">
|
<a href="#main-content" class="sr-only focus:not-sr-only focus:absolute focus:z-50 focus:p-4 focus:bg-white focus:text-black focus:outline-none focus:ring-2 focus:ring-indigo-500">
|
||||||
@@ -35,5 +37,7 @@
|
|||||||
{{ $slot }}
|
{{ $slot }}
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@stack('scripts')
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
文件
|
文件
|
||||||
</x-nav-link>
|
</x-nav-link>
|
||||||
|
|
||||||
@if(Auth::user() && (Auth::user()->hasRole(['admin', 'membership_manager', 'finance_accountant', 'finance_cashier', 'staff']) || Auth::user()->canAny(['view_finance_documents', 'view_incomes', 'view_accounting_transactions', 'manage_system_settings'])))
|
@if(Auth::user() && (Auth::user()->hasRole(['admin', 'membership_manager', 'finance_accountant', 'finance_cashier', 'staff']) || Auth::user()->canAny(['view_finance_documents', 'view_incomes', 'view_accounting_transactions', 'manage_system_settings', 'view_articles', 'view_pages'])))
|
||||||
<div class="hidden sm:flex sm:items-center">
|
<div class="hidden sm:flex sm:items-center">
|
||||||
<x-dropdown align="right" width="48">
|
<x-dropdown align="right" width="48">
|
||||||
<x-slot name="trigger">
|
<x-slot name="trigger">
|
||||||
@@ -97,6 +97,23 @@
|
|||||||
文件管理
|
文件管理
|
||||||
</x-dropdown-link>
|
</x-dropdown-link>
|
||||||
@endhasrole
|
@endhasrole
|
||||||
|
@can('view_articles')
|
||||||
|
<div class="border-t border-gray-200 dark:border-gray-600 my-1"></div>
|
||||||
|
<div class="px-4 py-1 text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase tracking-wider">官網管理</div>
|
||||||
|
<x-dropdown-link :href="route('admin.articles.index')">
|
||||||
|
文章管理
|
||||||
|
</x-dropdown-link>
|
||||||
|
@endcan
|
||||||
|
@can('view_pages')
|
||||||
|
<x-dropdown-link :href="route('admin.pages.index')">
|
||||||
|
頁面管理
|
||||||
|
</x-dropdown-link>
|
||||||
|
@endcan
|
||||||
|
@can('view_articles')
|
||||||
|
<x-dropdown-link :href="route('admin.article-categories.index')">
|
||||||
|
文章分類
|
||||||
|
</x-dropdown-link>
|
||||||
|
@endcan
|
||||||
@can('manage_system_settings')
|
@can('manage_system_settings')
|
||||||
<x-dropdown-link :href="route('admin.settings.general')">
|
<x-dropdown-link :href="route('admin.settings.general')">
|
||||||
系統設定
|
系統設定
|
||||||
@@ -170,7 +187,7 @@
|
|||||||
文件
|
文件
|
||||||
</x-responsive-nav-link>
|
</x-responsive-nav-link>
|
||||||
|
|
||||||
@if(Auth::user() && (Auth::user()->hasRole(['admin', 'membership_manager', 'finance_accountant', 'finance_cashier', 'staff']) || Auth::user()->canAny(['view_finance_documents', 'view_incomes', 'view_accounting_transactions', 'manage_system_settings'])))
|
@if(Auth::user() && (Auth::user()->hasRole(['admin', 'membership_manager', 'finance_accountant', 'finance_cashier', 'staff']) || Auth::user()->canAny(['view_finance_documents', 'view_incomes', 'view_accounting_transactions', 'manage_system_settings', 'view_articles', 'view_pages'])))
|
||||||
<div class="pt-2 pb-1 border-t border-gray-200 dark:border-gray-700 mt-2">
|
<div class="pt-2 pb-1 border-t border-gray-200 dark:border-gray-700 mt-2">
|
||||||
<div class="px-4 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider">
|
<div class="px-4 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider">
|
||||||
管理
|
管理
|
||||||
@@ -233,6 +250,26 @@
|
|||||||
文件管理
|
文件管理
|
||||||
</x-responsive-nav-link>
|
</x-responsive-nav-link>
|
||||||
@endhasrole
|
@endhasrole
|
||||||
|
@can('view_articles')
|
||||||
|
<div class="pt-2 pb-1 border-t border-gray-200 dark:border-gray-700 mt-2">
|
||||||
|
<div class="px-4 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider">
|
||||||
|
官網管理
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<x-responsive-nav-link :href="route('admin.articles.index')" :active="request()->routeIs('admin.articles.*')">
|
||||||
|
文章管理
|
||||||
|
</x-responsive-nav-link>
|
||||||
|
@endcan
|
||||||
|
@can('view_pages')
|
||||||
|
<x-responsive-nav-link :href="route('admin.pages.index')" :active="request()->routeIs('admin.pages.*')">
|
||||||
|
頁面管理
|
||||||
|
</x-responsive-nav-link>
|
||||||
|
@endcan
|
||||||
|
@can('view_articles')
|
||||||
|
<x-responsive-nav-link :href="route('admin.article-categories.index')" :active="request()->routeIs('admin.article-categories.*')">
|
||||||
|
文章分類
|
||||||
|
</x-responsive-nav-link>
|
||||||
|
@endcan
|
||||||
@can('manage_system_settings')
|
@can('manage_system_settings')
|
||||||
<x-responsive-nav-link :href="route('admin.settings.general')" :active="request()->routeIs('admin.settings.*')">
|
<x-responsive-nav-link :href="route('admin.settings.general')" :active="request()->routeIs('admin.settings.*')">
|
||||||
系統設定
|
系統設定
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Http\Controllers\Api\ArticleController;
|
||||||
|
use App\Http\Controllers\Api\HomepageController;
|
||||||
|
use App\Http\Controllers\Api\PageController;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
@@ -17,3 +20,28 @@ use Illuminate\Support\Facades\Route;
|
|||||||
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
|
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
|
||||||
return $request->user();
|
return $request->user();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Public API v1
|
||||||
|
Route::prefix('v1')->group(function () {
|
||||||
|
// Articles
|
||||||
|
Route::get('/articles', [ArticleController::class, 'index']);
|
||||||
|
Route::get('/articles/{slug}', [ArticleController::class, 'show']);
|
||||||
|
Route::get('/articles/{slug}/attachments/{id}/download', [ArticleController::class, 'downloadAttachment']);
|
||||||
|
|
||||||
|
// Categories
|
||||||
|
Route::get('/categories', function () {
|
||||||
|
$categories = \App\Models\ArticleCategory::withCount(['articles' => function ($q) {
|
||||||
|
$q->active()->forAccessLevel();
|
||||||
|
}])
|
||||||
|
->orderBy('sort_order')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return \App\Http\Resources\CategoryResource::collection($categories);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Pages
|
||||||
|
Route::get('/pages/{slug}', [PageController::class, 'show']);
|
||||||
|
|
||||||
|
// Homepage
|
||||||
|
Route::get('/homepage', [HomepageController::class, 'index']);
|
||||||
|
});
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ use App\Http\Controllers\PublicDocumentController;
|
|||||||
use App\Http\Controllers\Admin\DocumentController;
|
use App\Http\Controllers\Admin\DocumentController;
|
||||||
use App\Http\Controllers\Admin\DocumentCategoryController;
|
use App\Http\Controllers\Admin\DocumentCategoryController;
|
||||||
use App\Http\Controllers\Admin\AnnouncementController;
|
use App\Http\Controllers\Admin\AnnouncementController;
|
||||||
|
use App\Http\Controllers\Admin\ArticleController;
|
||||||
|
use App\Http\Controllers\Admin\ArticleCategoryController;
|
||||||
|
use App\Http\Controllers\Admin\ArticleTagController;
|
||||||
|
use App\Http\Controllers\Admin\PageController;
|
||||||
use App\Http\Controllers\PublicBugReportController;
|
use App\Http\Controllers\PublicBugReportController;
|
||||||
use App\Http\Controllers\IncomeController;
|
use App\Http\Controllers\IncomeController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
@@ -314,6 +318,51 @@ Route::middleware(['auth', 'admin'])->prefix('admin')->name('admin.')->group(fun
|
|||||||
Route::post('/announcements/{announcement}/pin', [AnnouncementController::class, 'pin'])->name('announcements.pin');
|
Route::post('/announcements/{announcement}/pin', [AnnouncementController::class, 'pin'])->name('announcements.pin');
|
||||||
Route::post('/announcements/{announcement}/unpin', [AnnouncementController::class, 'unpin'])->name('announcements.unpin');
|
Route::post('/announcements/{announcement}/unpin', [AnnouncementController::class, 'unpin'])->name('announcements.unpin');
|
||||||
|
|
||||||
|
// Article Management (官網文章管理)
|
||||||
|
Route::get('/articles', [ArticleController::class, 'index'])->name('articles.index');
|
||||||
|
Route::get('/articles/create', [ArticleController::class, 'create'])->name('articles.create');
|
||||||
|
Route::post('/articles', [ArticleController::class, 'store'])->name('articles.store');
|
||||||
|
Route::get('/articles/{article}', [ArticleController::class, 'show'])->name('articles.show');
|
||||||
|
Route::get('/articles/{article}/edit', [ArticleController::class, 'edit'])->name('articles.edit');
|
||||||
|
Route::patch('/articles/{article}', [ArticleController::class, 'update'])->name('articles.update');
|
||||||
|
Route::delete('/articles/{article}', [ArticleController::class, 'destroy'])->name('articles.destroy');
|
||||||
|
|
||||||
|
// Article Actions
|
||||||
|
Route::post('/articles/{article}/publish', [ArticleController::class, 'publish'])->name('articles.publish');
|
||||||
|
Route::post('/articles/{article}/archive', [ArticleController::class, 'archive'])->name('articles.archive');
|
||||||
|
Route::post('/articles/{article}/pin', [ArticleController::class, 'pin'])->name('articles.pin');
|
||||||
|
Route::post('/articles/{article}/unpin', [ArticleController::class, 'unpin'])->name('articles.unpin');
|
||||||
|
|
||||||
|
// Article Attachments
|
||||||
|
Route::post('/articles/{article}/attachments', [ArticleController::class, 'uploadAttachment'])->name('articles.attachments.store');
|
||||||
|
Route::delete('/articles/{article}/attachments/{attachment}', [ArticleController::class, 'deleteAttachment'])->name('articles.attachments.destroy');
|
||||||
|
|
||||||
|
// Article Categories Management
|
||||||
|
Route::get('/article-categories', [ArticleCategoryController::class, 'index'])->name('article-categories.index');
|
||||||
|
Route::get('/article-categories/create', [ArticleCategoryController::class, 'create'])->name('article-categories.create');
|
||||||
|
Route::post('/article-categories', [ArticleCategoryController::class, 'store'])->name('article-categories.store');
|
||||||
|
Route::get('/article-categories/{articleCategory}/edit', [ArticleCategoryController::class, 'edit'])->name('article-categories.edit');
|
||||||
|
Route::patch('/article-categories/{articleCategory}', [ArticleCategoryController::class, 'update'])->name('article-categories.update');
|
||||||
|
Route::delete('/article-categories/{articleCategory}', [ArticleCategoryController::class, 'destroy'])->name('article-categories.destroy');
|
||||||
|
|
||||||
|
// Article Tags Management
|
||||||
|
Route::get('/article-tags', [ArticleTagController::class, 'index'])->name('article-tags.index');
|
||||||
|
Route::get('/article-tags/create', [ArticleTagController::class, 'create'])->name('article-tags.create');
|
||||||
|
Route::post('/article-tags', [ArticleTagController::class, 'store'])->name('article-tags.store');
|
||||||
|
Route::get('/article-tags/{articleTag}/edit', [ArticleTagController::class, 'edit'])->name('article-tags.edit');
|
||||||
|
Route::patch('/article-tags/{articleTag}', [ArticleTagController::class, 'update'])->name('article-tags.update');
|
||||||
|
Route::delete('/article-tags/{articleTag}', [ArticleTagController::class, 'destroy'])->name('article-tags.destroy');
|
||||||
|
|
||||||
|
// Page Management (官網頁面管理)
|
||||||
|
Route::get('/pages', [PageController::class, 'index'])->name('pages.index');
|
||||||
|
Route::get('/pages/create', [PageController::class, 'create'])->name('pages.create');
|
||||||
|
Route::post('/pages', [PageController::class, 'store'])->name('pages.store');
|
||||||
|
Route::get('/pages/{page}', [PageController::class, 'show'])->name('pages.show');
|
||||||
|
Route::get('/pages/{page}/edit', [PageController::class, 'edit'])->name('pages.edit');
|
||||||
|
Route::patch('/pages/{page}', [PageController::class, 'update'])->name('pages.update');
|
||||||
|
Route::delete('/pages/{page}', [PageController::class, 'destroy'])->name('pages.destroy');
|
||||||
|
Route::post('/pages/{page}/publish', [PageController::class, 'publish'])->name('pages.publish');
|
||||||
|
|
||||||
// System Settings (requires manage_system_settings permission)
|
// System Settings (requires manage_system_settings permission)
|
||||||
Route::middleware('can:manage_system_settings')->prefix('settings')->name('settings.')->group(function () {
|
Route::middleware('can:manage_system_settings')->prefix('settings')->name('settings.')->group(function () {
|
||||||
Route::get('/', [\App\Http\Controllers\Admin\SystemSettingsController::class, 'index'])->name('index');
|
Route::get('/', [\App\Http\Controllers\Admin\SystemSettingsController::class, 'index'])->name('index');
|
||||||
|
|||||||
Reference in New Issue
Block a user