NIM_E31222518/resources/views/admin/barang/index.blade.php

87 lines
4.5 KiB
PHP

@extends('layouts.admin')
@section('content')
<div class="mb-6 flex justify-between items-center">
<h1 class="text-2xl font-bold text-gray-800">Data Barang</h1>
<a href="{{ route('admin.barang.create') }}" class="bg-[#2c7a7b] hover:bg-[#246c6d] text-white px-4 py-2 rounded-lg">
<i class="fas fa-plus mr-2"></i>Tambah Barang
</a>
</div>
@if(session('success'))
<div class="mb-4 p-4 bg-green-100 border border-green-400 text-green-700 rounded">
{{ session('success') }}
</div>
@endif
<div class="bg-white rounded-lg shadow overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Gambar</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nama</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Stok</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Kategori</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Harga</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Aksi</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@forelse($barang as $item)
<tr>
<td class="px-6 py-4 whitespace-nowrap">
@if ($item->gambar)
<img src="{{ Storage::url($item->gambar) }}" alt="{{ $item->nama_barang }}" class="w-16 h-16 object-cover rounded">
@else
<div class="w-16 h-16 bg-gray-200 flex items-center justify-center rounded">
<span class="text-gray-500"><i class="fas fa-image"></i></span>
</div>
@endif
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm font-medium text-gray-900">{{ $item->nama_barang }}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-900">{{ $item->stok }}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
{{ $item->kategori }}
</span>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-900">Rp {{ number_format($item->harga, 0, ',', '.') }}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
<div class="flex space-x-2">
<a href="{{ route('admin.barang.show', $item) }}" class="text-blue-600 hover:text-blue-900">
<i class="fas fa-eye"></i>
</a>
<a href="{{ route('admin.barang.edit', $item) }}" class="text-indigo-600 hover:text-indigo-900">
<i class="fas fa-edit"></i>
</a>
<form action="{{ route('admin.barang.destroy', $item) }}" method="POST" class="inline" onsubmit="return confirm('Yakin ingin menghapus barang ini?')">
@csrf
@method('DELETE')
<button type="submit" class="text-red-600 hover:text-red-900">
<i class="fas fa-trash"></i>
</button>
</form>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="6" class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 text-center">
Tidak ada data barang
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
@endsection