初始化
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
@extends('admin.layout')
|
||||
|
||||
@php $editing = isset($category) && $category; @endphp
|
||||
|
||||
@section('title', $editing ? '编辑分类' : '新建分类')
|
||||
@section('page-title', $editing ? '编辑分类' : '新建分类')
|
||||
|
||||
@section('content')
|
||||
<form method="POST" action="{{ $editing ? route('admin.categories.update', $category) : route('admin.categories.store') }}" class="form-card">
|
||||
@csrf
|
||||
@if ($editing) @method('PUT') @endif
|
||||
|
||||
<div class="field">
|
||||
<label>名称</label>
|
||||
<input name="name" class="input" value="{{ old('name', $category?->name ?? '') }}" required>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Slug</label>
|
||||
<input name="slug" class="input" value="{{ old('slug', $category?->slug ?? '') }}" required>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>类型</label>
|
||||
<select name="type" class="select">
|
||||
<option value="product" @selected(old('type', $category?->type ?? 'product') === 'product')>产品</option>
|
||||
<option value="article" @selected(old('type', $category?->type ?? '') === 'article')>文章</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>排序</label>
|
||||
<input type="number" name="sort" class="input" value="{{ old('sort', $category?->sort ?? 0) }}">
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<button class="btn btn-primary">保存</button>
|
||||
<a href="{{ route('admin.categories.index') }}" class="btn">取消</a>
|
||||
</div>
|
||||
</form>
|
||||
@endsection
|
||||
@@ -0,0 +1,32 @@
|
||||
@extends('admin.layout')
|
||||
|
||||
@section('title', '分类管理')
|
||||
@section('page-title', '分类管理')
|
||||
@section('actions')
|
||||
<a href="{{ route('admin.categories.create') }}" class="btn btn-primary btn-sm"><x-icon name="plus" :size="16"/> 新建分类</a>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<table class="data-table">
|
||||
<thead><tr><th>名称</th><th>类型</th><th>排序</th><th class="col-op">操作</th></tr></thead>
|
||||
<tbody>
|
||||
@forelse ($categories as $c)
|
||||
<tr>
|
||||
<td>{{ $c->name }} <span class="muted">/ {{ $c->slug }}</span></td>
|
||||
<td>{{ $c->type === 'product' ? '产品' : '文章' }}</td>
|
||||
<td>{{ $c->sort }}</td>
|
||||
<td class="row-actions">
|
||||
<a href="{{ route('admin.categories.edit', $c) }}" class="btn btn-sm"><x-icon name="edit" :size="16"/></a>
|
||||
<form method="POST" action="{{ route('admin.categories.destroy', $c) }}" onsubmit="return confirm('确认删除该分类?')">
|
||||
@csrf @method('DELETE')
|
||||
<button class="btn btn-sm btn-danger"><x-icon name="trash" :size="16"/></button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="4" class="muted">暂无分类。</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
{{ $categories->links('pagination::bootstrap-5') }}
|
||||
@endsection
|
||||
Reference in New Issue
Block a user