85 lines
3.8 KiB
PHP
85 lines
3.8 KiB
PHP
@extends('admin.layout')
|
||
|
||
@php $editing = isset($article) && $article; @endphp
|
||
|
||
@section('title', $editing ? '编辑文章' : '新建文章')
|
||
@section('page-title', $editing ? '编辑文章' : '新建文章')
|
||
|
||
@section('content')
|
||
<form method="POST" action="{{ $editing ? route('admin.articles.update', $article) : route('admin.articles.store') }}" class="form-card">
|
||
@csrf
|
||
@if ($editing) @method('PUT') @endif
|
||
|
||
<div class="field">
|
||
<label>标题</label>
|
||
<input name="title" class="input" value="{{ old('title', $article?->title ?? '') }}" required>
|
||
</div>
|
||
<div class="field">
|
||
<label>Slug</label>
|
||
<input name="slug" class="input" value="{{ old('slug', $article?->slug ?? '') }}" required>
|
||
</div>
|
||
<div class="field">
|
||
<label>分类</label>
|
||
<select name="category_id" class="select">
|
||
<option value="">无分类</option>
|
||
@foreach ($categories as $c)
|
||
<option value="{{ $c->id }}" @selected(old('category_id', $article?->category_id) == $c->id)>{{ $c->name }}</option>
|
||
@endforeach
|
||
</select>
|
||
</div>
|
||
<div class="field">
|
||
<label>作者</label>
|
||
<input name="author" class="input" value="{{ old('author', $article?->author ?? '') }}">
|
||
</div>
|
||
<div class="field">
|
||
<label>摘要</label>
|
||
<input name="summary" class="input" value="{{ old('summary', $article?->summary ?? '') }}">
|
||
</div>
|
||
<div class="field">
|
||
<label>正文(富文本)</label>
|
||
<x-rich-editor name="body" :value="old('body', $article?->body ?? '')" />
|
||
</div>
|
||
<div class="field">
|
||
<label>封面图(可选,支持上传)</label>
|
||
<input type="file" id="cover-file" accept="image/*" style="margin-bottom:8px;">
|
||
<div style="display:flex; gap:8px; align-items:center;">
|
||
<input name="cover" id="cover-url" class="input" style="flex:1;" value="{{ old('cover', $article?->cover ?? '') }}" placeholder="图片地址(可上传或粘贴 URL)">
|
||
<button type="button" class="btn" onclick="uploadFile('cover')">上传</button>
|
||
</div>
|
||
<p class="form-hint">仅「专题报道」版式会使用封面图。支持 jpg/png/gif/webp,单张 ≤ 5MB。</p>
|
||
</div>
|
||
<div class="field">
|
||
<label>状态</label>
|
||
<select name="status" class="select">
|
||
<option value="approved" @selected(old('status', $article?->status ?? 'approved') === 'approved')>已发布</option>
|
||
<option value="draft" @selected(old('status', $article?->status ?? '') === 'draft')>草稿</option>
|
||
</select>
|
||
</div>
|
||
<div class="field">
|
||
<label>版式模板</label>
|
||
<select name="template" class="select">
|
||
@foreach (App\Models\Article::TEMPLATES as $key => $label)
|
||
<option value="{{ $key }}" @selected(old('template', $article?->template ?? 'standard') === $key)>{{ $label }}</option>
|
||
@endforeach
|
||
</select>
|
||
</div>
|
||
<div class="field">
|
||
<label>SEO 标题(留空则使用文章标题)</label>
|
||
<input name="seo_title" class="input" value="{{ old('seo_title', $article?->seo_title ?? '') }}">
|
||
</div>
|
||
<div class="field">
|
||
<label>SEO 描述(留空则使用摘要)</label>
|
||
<input name="seo_description" class="input" value="{{ old('seo_description', $article?->seo_description ?? '') }}">
|
||
</div>
|
||
<div class="field">
|
||
<label>发布时间</label>
|
||
<input type="date" name="published_at" class="input" value="{{ old('published_at', $article?->published_at?->format('Y-m-d')) }}">
|
||
</div>
|
||
|
||
<div class="form-actions">
|
||
<button class="btn btn-primary">保存</button>
|
||
<a href="{{ route('admin.articles.index') }}" class="btn">取消</a>
|
||
</div>
|
||
</form>
|
||
@endsection
|