init
This commit is contained in:
58
resources/views/admin/categories/form.blade.php
Normal file
58
resources/views/admin/categories/form.blade.php
Normal file
@@ -0,0 +1,58 @@
|
||||
@extends('layouts.admin')
|
||||
|
||||
@section('title', $item->exists ? '编辑分类' : '新建分类')
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h3 class="card-title mb-0">{{ $item->exists ? '编辑分类' : '新建分类' }}</h3>
|
||||
<a class="btn btn-sm btn-outline-secondary" href="{{ route('admin.categories.index') }}">返回列表</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="post" action="{{ $submitRoute }}" class="row g-3">
|
||||
@csrf
|
||||
@if($method !== 'POST') @method($method) @endif
|
||||
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">类型</label>
|
||||
<input class="form-control" list="categoryTypeList" name="type" value="{{ old('type', $item->type) }}" required placeholder="tool / model / news / guide">
|
||||
<datalist id="categoryTypeList">
|
||||
@foreach($typeOptions as $type)
|
||||
<option value="{{ $type }}"></option>
|
||||
@endforeach
|
||||
<option value="tool"></option>
|
||||
<option value="model"></option>
|
||||
<option value="news"></option>
|
||||
<option value="guide"></option>
|
||||
</datalist>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">名称</label>
|
||||
<input class="form-control" name="name" value="{{ old('name', $item->name) }}" required>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Slug</label>
|
||||
<input class="form-control" name="slug" value="{{ old('slug', $item->slug) }}" required>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<label class="form-label">描述</label>
|
||||
<textarea class="form-control" name="description" rows="3">{{ old('description', $item->description) }}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<label class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="is_active" value="1" @checked(old('is_active', $item->is_active ?? true))>
|
||||
<span class="form-check-label">启用分类</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<button class="btn btn-primary" type="submit">保存</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
62
resources/views/admin/categories/index.blade.php
Normal file
62
resources/views/admin/categories/index.blade.php
Normal file
@@ -0,0 +1,62 @@
|
||||
@extends('layouts.admin')
|
||||
|
||||
@section('title', '分类管理')
|
||||
|
||||
@section('content')
|
||||
<div class="card mb-3">
|
||||
<div class="card-body d-flex flex-column flex-lg-row gap-2 align-items-lg-center justify-content-between">
|
||||
<form method="get" action="{{ route('admin.categories.index') }}" class="d-flex flex-column flex-md-row gap-2 w-100">
|
||||
<input class="form-control" type="text" name="q" value="{{ $filters['q'] ?? '' }}" placeholder="搜索分类名称 / Slug">
|
||||
<select class="form-select" name="type" style="max-width: 180px;">
|
||||
<option value="">全部类型</option>
|
||||
@foreach($typeOptions as $type)
|
||||
<option value="{{ $type }}" @selected(($filters['type'] ?? '') === $type)>{{ $type }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<button class="btn btn-primary" type="submit"><i class="bi bi-search me-1"></i>搜索</button>
|
||||
</form>
|
||||
<a class="btn btn-success" href="{{ route('admin.categories.create') }}"><i class="bi bi-plus-circle me-1"></i>新建分类</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-vcenter card-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th>类型</th>
|
||||
<th>Slug</th>
|
||||
<th>状态</th>
|
||||
<th>更新时间</th>
|
||||
<th class="text-end">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse($items as $item)
|
||||
<tr>
|
||||
<td>
|
||||
<div class="fw-semibold">{{ $item->name }}</div>
|
||||
<div class="text-muted small">{{ $item->description ?: '-' }}</div>
|
||||
</td>
|
||||
<td><span class="badge bg-indigo-lt text-indigo-fg">{{ $item->type }}</span></td>
|
||||
<td><code>{{ $item->slug }}</code></td>
|
||||
<td>
|
||||
@if($item->is_active)
|
||||
<span class="badge bg-green-lt text-green-fg">启用</span>
|
||||
@else
|
||||
<span class="badge bg-secondary-lt">停用</span>
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $item->updated_at?->format('Y-m-d H:i') }}</td>
|
||||
<td class="text-end"><a class="btn btn-sm btn-outline-primary" href="{{ route('admin.categories.edit', $item) }}">编辑</a></td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="6" class="text-center text-muted py-4">暂无分类数据</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer">{{ $items->links() }}</div>
|
||||
</div>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user