First commit
This commit is contained in:
59
resources/views/admin/categories/_form.blade.php
Normal file
59
resources/views/admin/categories/_form.blade.php
Normal file
@@ -0,0 +1,59 @@
|
||||
{{-- Partial form untuk create dan edit kategori --}}
|
||||
<div class="row g-3">
|
||||
<div class="col-12">
|
||||
<label class="form-label fw-semibold">Nama Kategori <span class="text-danger">*</span></label>
|
||||
<input type="text" name="name" class="form-control @error('name') is-invalid @enderror"
|
||||
value="{{ old('name', $category->name ?? '') }}" required
|
||||
placeholder="Contoh: Pelesenan">
|
||||
@error('name')<div class="invalid-feedback">{{ $message }}</div>@enderror
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<label class="form-label fw-semibold">Slug</label>
|
||||
<input type="text" name="slug" class="form-control @error('slug') is-invalid @enderror"
|
||||
value="{{ old('slug', $category->slug ?? '') }}"
|
||||
placeholder="Auto-generated jika kosong (contoh: pelesenan)">
|
||||
<div class="form-text">Huruf kecil, angka, dan tanda (-) sahaja. Digunakan untuk URL.</div>
|
||||
@error('slug')<div class="invalid-feedback">{{ $message }}</div>@enderror
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<label class="form-label fw-semibold">Deskripsi</label>
|
||||
<textarea name="description" class="form-control" rows="2"
|
||||
placeholder="Huraian ringkas tentang kategori ini...">{{ old('description', $category->description ?? '') }}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Warna</label>
|
||||
<div class="input-group">
|
||||
<input type="color" name="color" class="form-control form-control-color"
|
||||
value="{{ old('color', $category->color ?? '#6c757d') }}" style="width:50px">
|
||||
<input type="text" class="form-control" id="colorText"
|
||||
value="{{ old('color', $category->color ?? '#6c757d') }}"
|
||||
placeholder="#6c757d" readonly>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-semibold">Urutan Paparan</label>
|
||||
<input type="number" name="sort_order" class="form-control"
|
||||
value="{{ old('sort_order', $category->sort_order ?? 0) }}" min="0">
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<div class="form-check form-switch">
|
||||
<input type="hidden" name="is_active" value="0">
|
||||
<input class="form-check-input" type="checkbox" name="is_active" value="1"
|
||||
id="isActive" {{ old('is_active', $category->is_active ?? true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="isActive">Kategori Aktif</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
$('input[type="color"]').on('input', function() {
|
||||
$('#colorText').val($(this).val());
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
32
resources/views/admin/categories/create.blade.php
Normal file
32
resources/views/admin/categories/create.blade.php
Normal file
@@ -0,0 +1,32 @@
|
||||
@extends('layouts.admin')
|
||||
|
||||
@section('title', 'Tambah Kategori')
|
||||
|
||||
@section('breadcrumb')
|
||||
<li class="breadcrumb-item"><a href="{{ route('admin.categories.index') }}">Kategori</a></li>
|
||||
<li class="breadcrumb-item active">Tambah</li>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-6">
|
||||
<div class="card border-0 shadow-sm">
|
||||
<div class="card-header bg-white border-bottom">
|
||||
<h5 class="mb-0 fw-bold"><i class="bi bi-folder-plus me-2"></i>Tambah Kategori Baru</h5>
|
||||
</div>
|
||||
<div class="card-body p-4">
|
||||
<form method="POST" action="{{ route('admin.categories.store') }}">
|
||||
@csrf
|
||||
@include('admin.categories._form')
|
||||
<div class="d-flex gap-2 mt-4 pt-3 border-top">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-save me-1"></i>Simpan
|
||||
</button>
|
||||
<a href="{{ route('admin.categories.index') }}" class="btn btn-outline-secondary">Batal</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
32
resources/views/admin/categories/edit.blade.php
Normal file
32
resources/views/admin/categories/edit.blade.php
Normal file
@@ -0,0 +1,32 @@
|
||||
@extends('layouts.admin')
|
||||
|
||||
@section('title', 'Edit Kategori')
|
||||
|
||||
@section('breadcrumb')
|
||||
<li class="breadcrumb-item"><a href="{{ route('admin.categories.index') }}">Kategori</a></li>
|
||||
<li class="breadcrumb-item active">Edit</li>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-6">
|
||||
<div class="card border-0 shadow-sm">
|
||||
<div class="card-header bg-white border-bottom">
|
||||
<h5 class="mb-0 fw-bold"><i class="bi bi-pencil me-2"></i>Edit Kategori: {{ $category->name }}</h5>
|
||||
</div>
|
||||
<div class="card-body p-4">
|
||||
<form method="POST" action="{{ route('admin.categories.update', $category) }}">
|
||||
@csrf @method('PUT')
|
||||
@include('admin.categories._form')
|
||||
<div class="d-flex gap-2 mt-4 pt-3 border-top">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-save me-1"></i>Kemaskini
|
||||
</button>
|
||||
<a href="{{ route('admin.categories.index') }}" class="btn btn-outline-secondary">Batal</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
101
resources/views/admin/categories/index.blade.php
Normal file
101
resources/views/admin/categories/index.blade.php
Normal file
@@ -0,0 +1,101 @@
|
||||
@extends('layouts.admin')
|
||||
|
||||
@section('title', 'Kategori')
|
||||
|
||||
@section('breadcrumb')
|
||||
<li class="breadcrumb-item active">Kategori</li>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="d-flex align-items-center justify-content-between mb-4">
|
||||
<h4 class="mb-0 fw-bold">Pengurusan Kategori</h4>
|
||||
<a href="{{ route('admin.categories.create') }}" class="btn btn-primary">
|
||||
<i class="bi bi-plus-circle me-1"></i>Tambah Kategori
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="card border-0 shadow-sm">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th class="ps-3">Nama</th>
|
||||
<th>Slug</th>
|
||||
<th>Dokumen</th>
|
||||
<th>Knowledge Items</th>
|
||||
<th>Status</th>
|
||||
<th>Urutan</th>
|
||||
<th class="text-end pe-3">Tindakan</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse($categories as $cat)
|
||||
<tr class="{{ $cat->trashed() ? 'opacity-50' : '' }}">
|
||||
<td class="ps-3">
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<span class="d-inline-block rounded-circle"
|
||||
style="width:12px;height:12px;background:{{ $cat->color ?? '#6c757d' }}"></span>
|
||||
<span class="fw-semibold">{{ $cat->name }}</span>
|
||||
</div>
|
||||
@if($cat->description)
|
||||
<small class="text-muted">{{ Str::limit($cat->description, 60) }}</small>
|
||||
@endif
|
||||
</td>
|
||||
<td><code class="small">{{ $cat->slug }}</code></td>
|
||||
<td>
|
||||
<span class="badge bg-light text-dark border">{{ $cat->total_documents ?? 0 }}</span>
|
||||
<small class="text-muted ms-1">({{ $cat->active_documents ?? 0 }} aktif)</small>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge bg-light text-dark border">{{ $cat->total_knowledge_items ?? 0 }}</span>
|
||||
</td>
|
||||
<td>
|
||||
@if($cat->trashed())
|
||||
<span class="badge bg-danger">Dipadam</span>
|
||||
@elseif($cat->is_active)
|
||||
<span class="badge bg-success">Aktif</span>
|
||||
@else
|
||||
<span class="badge bg-secondary">Tidak Aktif</span>
|
||||
@endif
|
||||
</td>
|
||||
<td><small>{{ $cat->sort_order }}</small></td>
|
||||
<td class="text-end pe-3">
|
||||
@unless($cat->trashed())
|
||||
<a href="{{ route('admin.categories.edit', $cat) }}"
|
||||
class="btn btn-sm btn-outline-secondary">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
<form method="POST" action="{{ route('admin.categories.toggle-status', $cat) }}" class="d-inline">
|
||||
@csrf @method('PATCH')
|
||||
<button type="submit" class="btn btn-sm {{ $cat->is_active ? 'btn-outline-warning' : 'btn-outline-success' }}"
|
||||
title="{{ $cat->is_active ? 'Nyahaktifkan' : 'Aktifkan' }}">
|
||||
<i class="bi {{ $cat->is_active ? 'bi-toggle-on' : 'bi-toggle-off' }}"></i>
|
||||
</button>
|
||||
</form>
|
||||
<form method="POST" action="{{ route('admin.categories.destroy', $cat) }}" class="d-inline"
|
||||
onsubmit="return confirm('Padam kategori ini? Dokumen aktif tidak boleh dipadam.')">
|
||||
@csrf @method('DELETE')
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
@endunless
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="7" class="text-center text-muted py-5">
|
||||
Tiada kategori. <a href="{{ route('admin.categories.create') }}">Tambah kategori pertama.</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@if($categories->hasPages())
|
||||
<div class="card-footer bg-white border-top py-3">
|
||||
{{ $categories->links() }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user