Files
ChatbotAI/resources/views/admin/knowledge-items/index.blade.php
2026-05-18 08:56:23 +08:00

143 lines
6.3 KiB
PHP

@extends('layouts.admin')
@section('title', 'FAQ & Pengetahuan')
@section('breadcrumb')
<li class="breadcrumb-item active">FAQ & Pengetahuan</li>
@endsection
@section('content')
<div class="d-flex align-items-center justify-content-between mb-4">
<h4 class="mb-0 fw-bold">FAQ & Pengetahuan</h4>
<a href="{{ route('admin.knowledge-items.create') }}" class="btn btn-primary">
<i class="bi bi-plus-circle me-1"></i>Tambah Item
</a>
</div>
{{-- Filter --}}
<div class="card border-0 shadow-sm mb-4">
<div class="card-body py-3">
<form method="GET" class="row g-2 align-items-end">
<div class="col-md-4">
<input type="text" name="search" class="form-control form-control-sm"
placeholder="Cari tajuk atau kandungan..." value="{{ request('search') }}">
</div>
<div class="col-md-3">
<select name="category_id" class="form-select form-select-sm">
<option value="">Semua Kategori</option>
@foreach($categories as $cat)
<option value="{{ $cat->id }}" {{ request('category_id') == $cat->id ? 'selected' : '' }}>
{{ $cat->name }}
</option>
@endforeach
</select>
</div>
<div class="col-md-2">
<select name="item_type" class="form-select form-select-sm">
<option value="">Semua Jenis</option>
@foreach($typeLabels as $value => $label)
<option value="{{ $value }}" {{ request('item_type') == $value ? 'selected' : '' }}>
{{ $label }}
</option>
@endforeach
</select>
</div>
<div class="col-auto">
<button type="submit" class="btn btn-sm btn-outline-secondary">
<i class="bi bi-search me-1"></i>Tapis
</button>
</div>
</form>
</div>
</div>
{{-- Table --}}
<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">Tajuk / Soalan</th>
<th>Kategori</th>
<th>Jenis</th>
<th>Status</th>
<th>Embed</th>
<th class="text-end pe-3">Tindakan</th>
</tr>
</thead>
<tbody>
@forelse($items as $item)
<tr class="{{ $item->trashed() ? 'opacity-50' : '' }}">
<td class="ps-3">
<div class="fw-semibold">{{ Str::limit($item->title, 80) }}</div>
<small class="text-muted">{{ Str::limit(strip_tags($item->content), 80) }}</small>
</td>
<td>
<span class="badge" style="background:{{ $item->category->color ?? '#6c757d' }}">
{{ $item->category->name }}
</span>
</td>
<td>
@php
$typeColors = ['faq' => 'bg-primary', 'policy' => 'bg-success', 'note' => 'bg-warning', 'announcement' => 'bg-info'];
@endphp
<span class="badge {{ $typeColors[$item->item_type] ?? 'bg-secondary' }}">
{{ $typeLabels[$item->item_type] ?? $item->item_type }}
</span>
</td>
<td>
@if($item->trashed())
<span class="badge bg-danger">Dipadam</span>
@elseif($item->is_active)
<span class="badge bg-success">Aktif</span>
@else
<span class="badge bg-secondary">Tidak Aktif</span>
@endif
</td>
<td>
@if($item->is_embedded)
<i class="bi bi-check-circle-fill text-success" title="Sudah di-embed"></i>
@else
<i class="bi bi-clock text-warning" title="Belum di-embed"></i>
@endif
</td>
<td class="text-end pe-3">
@unless($item->trashed())
<a href="{{ route('admin.knowledge-items.show', $item) }}"
class="btn btn-sm btn-outline-primary">
<i class="bi bi-eye"></i>
</a>
<a href="{{ route('admin.knowledge-items.edit', $item) }}"
class="btn btn-sm btn-outline-secondary">
<i class="bi bi-pencil"></i>
</a>
<form method="POST" action="{{ route('admin.knowledge-items.toggle-status', $item) }}" class="d-inline">
@csrf @method('PATCH')
<button type="submit" class="btn btn-sm {{ $item->is_active ? 'btn-outline-warning' : 'btn-outline-success' }}"
title="{{ $item->is_active ? 'Nyahaktifkan' : 'Aktifkan' }}">
<i class="bi {{ $item->is_active ? 'bi-toggle-on' : 'bi-toggle-off' }}"></i>
</button>
</form>
@endunless
</td>
</tr>
@empty
<tr>
<td colspan="6" class="text-center text-muted py-5">
<i class="bi bi-lightbulb fs-2 d-block mb-2 opacity-25"></i>
Tiada knowledge item ditemui.
<a href="{{ route('admin.knowledge-items.create') }}">Tambah yang pertama.</a>
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@if($items->hasPages())
<div class="card-footer bg-white border-top py-3">
{{ $items->links() }}
</div>
@endif
</div>
@endsection