[Update Kategori]

This commit is contained in:
Arief Dwi Wicaksono 2025-09-03 10:17:26 +07:00
parent 31a39e9642
commit aeb1d56e85

View File

@ -3,45 +3,52 @@
@section('title', 'Manajemen Kategori') @section('title', 'Manajemen Kategori')
@section('content') @section('content')
<div class="container"> <div class="container-fluid py-4">
<!-- Header --> <!-- Header -->
<div class="d-flex justify-content-between align-items-center mb-4"> <div class="d-flex justify-content-between align-items-center mb-4">
<h3 class="fw-bold">Manajemen Kategori</h3> <h3 class="fw-bold mb-0">Manajemen Kategori</h3>
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#modalTambah"> <button class="btn btn-primary px-3" data-bs-toggle="modal" data-bs-target="#modalTambah">
<i class="bi bi-plus-lg"></i> Tambah Kategori <i class="bi bi-plus-lg me-1"></i> Nambah Kategori
</button> </button>
</div> </div>
<!-- Tabel Kategori --> <!-- Tabel Kategori -->
<div class="card shadow-sm border-0"> <div class="card border-0 shadow-sm rounded-3">
<div class="card-body"> <div class="card-body">
<table class="table table-hover align-middle"> <table class="table table-borderless align-middle text-nowrap">
<thead> <thead class="table-light">
<tr> <tr>
<th width="50">No</th> <th width="50">Nomor</th>
<th>Nama Kategori</th>
<th>Keterangan</th>
<th>Foto</th> <th>Foto</th>
<th>Nama</th> <th width="150" class="text-center">Aksi</th>
<th>Deskripsi</th>
<th width="180">Aksi</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@forelse ($kategori as $key => $item) @forelse ($kategori as $key => $item)
<tr> <tr class="align-middle">
<td>{{ $key + 1 }}</td> <td>{{ $key + 1 }}</td>
<td>{{ $item->nama }}</td>
<td class="text-truncate" style="max-width:300px;">
{{ $item->deskripsi ?? '-' }}
</td>
<td> <td>
@if($item->foto) @if($item->foto)
<img src="{{ asset('storage/'.$item->foto) }}" alt="foto" width="50" height="50" style="object-fit:cover; border-radius:6px;"> <img src="{{ asset('storage/'.$item->foto) }}" alt="foto"
width="50" height="50"
class="rounded" style="object-fit:cover;">
@else @else
<img src="{{ asset('default-image.png') }}" alt="default" width="50" height="50" style="object-fit:cover; border-radius:6px;"> <img src="{{ asset('default-image.png') }}" alt="default"
width="50" height="50"
class="rounded" style="object-fit:cover;">
@endif @endif
</td> </td>
<td>{{ $item->nama }}</td> <td class="text-center">
<td>{{ $item->deskripsi ?? '-' }}</td> <button class="btn btn-link text-primary p-0 me-2"
<td> data-bs-toggle="modal"
<button class="btn btn-warning btn-sm" data-bs-toggle="modal"
data-bs-target="#modalEdit{{ $item->id }}"> data-bs-target="#modalEdit{{ $item->id }}">
<i class="bi bi-pencil"></i> <i class="bi bi-pencil me-1"></i> Ubah
</button> </button>
<form action="{{ route('admin.kategori.destroy', $item->id) }}" <form action="{{ route('admin.kategori.destroy', $item->id) }}"
method="POST" method="POST"
@ -49,8 +56,8 @@
onsubmit="return confirm('Yakin mau hapus kategori ini?')"> onsubmit="return confirm('Yakin mau hapus kategori ini?')">
@csrf @csrf
@method('DELETE') @method('DELETE')
<button class="btn btn-danger btn-sm"> <button class="btn btn-link text-danger p-0">
<i class="bi bi-trash"></i> <i class="bi bi-trash me-1"></i> Hapus
</button> </button>
</form> </form>
</td> </td>
@ -77,15 +84,15 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="mb-3"> <div class="mb-3">
<label>Nama</label> <label class="form-label">Nama</label>
<input type="text" name="nama" class="form-control" required> <input type="text" name="nama" class="form-control" required>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label>Deskripsi</label> <label class="form-label">Deskripsi</label>
<textarea name="deskripsi" class="form-control" rows="3"></textarea> <textarea name="deskripsi" class="form-control" rows="3"></textarea>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label>Foto</label> <label class="form-label">Foto</label>
<input type="file" name="foto" class="form-control"> <input type="file" name="foto" class="form-control">
</div> </div>
</div> </div>
@ -97,7 +104,7 @@
</div> </div>
</div> </div>
<!-- Modal Edit (Diletakkan di luar tabel) --> <!-- Modal Edit -->
@foreach ($kategori as $item) @foreach ($kategori as $item)
<div class="modal fade" id="modalEdit{{ $item->id }}" tabindex="-1"> <div class="modal fade" id="modalEdit{{ $item->id }}" tabindex="-1">
<div class="modal-dialog"> <div class="modal-dialog">
@ -110,15 +117,15 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="mb-3"> <div class="mb-3">
<label>Nama</label> <label class="form-label">Nama</label>
<input type="text" name="nama" value="{{ $item->nama }}" class="form-control" required> <input type="text" name="nama" value="{{ $item->nama }}" class="form-control" required>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label>Deskripsi</label> <label class="form-label">Deskripsi</label>
<textarea name="deskripsi" class="form-control" rows="3">{{ $item->deskripsi }}</textarea> <textarea name="deskripsi" class="form-control" rows="3">{{ $item->deskripsi }}</textarea>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label>Foto</label> <label class="form-label">Foto</label>
<input type="file" name="foto" class="form-control"> <input type="file" name="foto" class="form-control">
@if($item->foto) @if($item->foto)
<small class="text-muted">Foto saat ini:</small><br> <small class="text-muted">Foto saat ini:</small><br>