fix bug
This commit is contained in:
parent
c72c80bbd1
commit
642601da4c
@ -5,14 +5,17 @@ namespace App\Http\Controllers;
|
|||||||
|
|
||||||
use App\Models\Fitur;
|
use App\Models\Fitur;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\KategoriFitur;
|
||||||
|
|
||||||
class FiturController extends Controller
|
class FiturController extends Controller
|
||||||
{
|
{
|
||||||
// Tampilkan semua fitur
|
// Tampilkan semua fitur
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$fitur = Fitur::paginate(5);
|
$fitur = Fitur::with('kategoriFitur')->paginate(5);
|
||||||
return view('admin.fitur.index', compact('fitur'));
|
$kategoriFiturs = KategoriFitur::all();
|
||||||
|
|
||||||
|
return view('admin.fitur.index', compact('fitur', 'kategoriFiturs'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simpan fitur baru
|
// Simpan fitur baru
|
||||||
|
|||||||
@ -16,4 +16,11 @@ class Fitur extends Model
|
|||||||
'harga',
|
'harga',
|
||||||
'kategori_fitur_id',
|
'kategori_fitur_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
public function kategoriFitur()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(KategoriFitur::class, 'kategori_fitur_id');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,18 +51,23 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@forelse ($fitur as $key => $item)
|
@forelse ($fitur as $key => $item)
|
||||||
<tr class="hover:bg-gray-50">
|
<tr class="hover:bg-gray-50">
|
||||||
|
<!-- Nomor -->
|
||||||
<td class="py-5 px-2 border border-gray-300 text-center">
|
<td class="py-5 px-2 border border-gray-300 text-center">
|
||||||
{{ $fitur->firstItem() + $key }}
|
{{ $fitur->firstItem() + $key }}
|
||||||
</td>
|
</td>
|
||||||
|
<!-- Kategori -->
|
||||||
<td class="py-5 px-2 border border-gray-300 text-center">
|
<td class="py-5 px-2 border border-gray-300 text-center">
|
||||||
{{ $item->kategoriFitur->nama ?? '-' }}
|
{{ $item->kategoriFitur->deskripsi ?? '-' }}
|
||||||
</td>
|
</td>
|
||||||
|
<!-- Nama Fitur -->
|
||||||
<td class="py-5 px-2 border border-gray-300 truncate whitespace-nowrap">
|
<td class="py-5 px-2 border border-gray-300 truncate whitespace-nowrap">
|
||||||
{{ $item->deskripsi }}
|
{{ $item->deskripsi }}
|
||||||
</td>
|
</td>
|
||||||
|
<!-- Harga -->
|
||||||
<td class="py-5 px-2 border border-gray-300 text-center">
|
<td class="py-5 px-2 border border-gray-300 text-center">
|
||||||
Rp {{ number_format($item->harga, 0, ',', '.') }}
|
Rp {{ number_format($item->harga, 0, ',', '.') }}
|
||||||
</td>
|
</td>
|
||||||
|
<!-- Aksi -->
|
||||||
<td class="py-5 px-2 border border-gray-300 text-center">
|
<td class="py-5 px-2 border border-gray-300 text-center">
|
||||||
<div class="flex justify-center space-x-2">
|
<div class="flex justify-center space-x-2">
|
||||||
<button class="text-blue-600 flex items-center pr-4 openEditModalBtn"
|
<button class="text-blue-600 flex items-center pr-4 openEditModalBtn"
|
||||||
@ -85,6 +90,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<!-- Pagination -->
|
<!-- Pagination -->
|
||||||
<div class="p-4 flex justify-center">
|
<div class="p-4 flex justify-center">
|
||||||
<div class="flex space-x-1">
|
<div class="flex space-x-1">
|
||||||
@ -151,19 +157,22 @@
|
|||||||
<h5 class="text-lg font-medium">Tambah Fitur</h5>
|
<h5 class="text-lg font-medium">Tambah Fitur</h5>
|
||||||
</div>
|
</div>
|
||||||
<div class="p-4 space-y-4">
|
<div class="p-4 space-y-4">
|
||||||
|
<!-- Kategori -->
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium">Kategori Fitur</label>
|
<label class="block text-sm font-medium">Kategori Fitur</label>
|
||||||
<select name="kategori_fitur_id" class="w-full p-2 border rounded" required>
|
<select name="kategori_fitur_id" class="w-full p-2 border rounded" required>
|
||||||
<option value="">-- Pilih Kategori --</option>
|
<option value="">-- Pilih Kategori --</option>
|
||||||
@foreach(\App\Models\KategoriFitur::all() as $kategori)
|
@foreach(\App\Models\KategoriFitur::all() as $kategori)
|
||||||
<option value="{{ $kategori->id }}">{{ $kategori->nama }}</option>
|
<option value="{{ $kategori->id }}">{{ $kategori->deskripsi }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Nama Fitur -->
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium">Nama Fitur</label>
|
<label class="block text-sm font-medium">Nama Fitur</label>
|
||||||
<input type="text" name="deskripsi" class="w-full p-2 border rounded" required>
|
<input type="text" name="deskripsi" class="w-full p-2 border rounded" required>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Harga -->
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium">Harga</label>
|
<label class="block text-sm font-medium">Harga</label>
|
||||||
<input type="number" name="harga" step="100" min="0" class="w-full p-2 border rounded" required>
|
<input type="number" name="harga" step="100" min="0" class="w-full p-2 border rounded" required>
|
||||||
@ -190,22 +199,26 @@
|
|||||||
<h5 class="text-lg font-medium">Edit Fitur</h5>
|
<h5 class="text-lg font-medium">Edit Fitur</h5>
|
||||||
</div>
|
</div>
|
||||||
<div class="p-4 space-y-4">
|
<div class="p-4 space-y-4">
|
||||||
|
<!-- Kategori -->
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium">Kategori Fitur</label>
|
<label class="block text-sm font-medium">Kategori Fitur</label>
|
||||||
<select name="kategori_fitur_id" class="w-full p-2 border rounded" required>
|
<select name="kategori_fitur_id" class="w-full p-2 border rounded" required>
|
||||||
<option value="">-- Pilih Kategori --</option>
|
<option value="">-- Pilih Kategori --</option>
|
||||||
@foreach(\App\Models\KategoriFitur::all() as $kategori)
|
@foreach(\App\Models\KategoriFitur::all() as $kategori)
|
||||||
<option value="{{ $kategori->id }}" {{ $item->kategori_fitur_id == $kategori->id ? 'selected' : '' }}>
|
<option value="{{ $kategori->id }}"
|
||||||
{{ $kategori->nama }}
|
{{ $item->kategori_fitur_id == $kategori->id ? 'selected' : '' }}>
|
||||||
|
{{ $kategori->deskripsi }}
|
||||||
</option>
|
</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Nama Fitur -->
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium">Nama Fitur</label>
|
<label class="block text-sm font-medium">Nama Fitur</label>
|
||||||
<input type="text" name="deskripsi" value="{{ $item->deskripsi }}"
|
<input type="text" name="deskripsi" value="{{ $item->deskripsi }}"
|
||||||
class="w-full p-2 border rounded" required>
|
class="w-full p-2 border rounded" required>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Harga -->
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium">Harga</label>
|
<label class="block text-sm font-medium">Harga</label>
|
||||||
<input type="number" name="harga" value="{{ $item->harga }}"
|
<input type="number" name="harga" value="{{ $item->harga }}"
|
||||||
@ -222,6 +235,7 @@
|
|||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
|
||||||
<!-- Modal Hapus -->
|
<!-- Modal Hapus -->
|
||||||
@foreach ($fitur as $item)
|
@foreach ($fitur as $item)
|
||||||
<div id="modalDelete{{ $item->id }}" class="fixed inset-0 hidden items-center justify-center z-50">
|
<div id="modalDelete{{ $item->id }}" class="fixed inset-0 hidden items-center justify-center z-50">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user