MIF_E31222629/resources/views/mobil/index.blade.php

88 lines
5.3 KiB
PHP

@extends('template.admin')
@section('content')
<div class="max-w-6xl mx-auto p-6 bg-white shadow-md rounded-lg">
<div class="flex items-center justify-between mb-6">
<h1 class="text-lg font-semibold text-gray-800 border-b pb-2">Data Mobil</h1>
<a href="{{ route('mobil.create') }}"
class="flex items-center gap-2 bg-[#1e3a8a] text-white px-4 py-2 rounded hover:bg-[#163570] transition">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4v16m8-8H4" />
</svg>
Tambah Mobil
</a>
</div>
<form action="{{ route('mobil.index') }}" method="GET" class="mb-4 flex items-center justify-end gap-2">
<input type="text" name="search" value="{{ request('search') }}"
class="border border-gray-300 rounded px-4 py-2 text-sm focus:ring focus:outline-none focus:border-[#1e3a8a]"
placeholder="Cari nama mobil...">
<button type="submit"
class="bg-[#1e3a8a] text-white px-4 py-2 rounded hover:bg-[#163570] transition text-sm">
Cari
</button>
</form>
<table class="w-full table-auto border-collapse text-sm text-gray-700">
<thead>
<tr class="bg-gray-50">
<th class="border-b border-gray-200 px-4 py-2 text-left font-medium text-gray-600">#</th>
<th class="border-b border-gray-200 px-4 py-2 text-left font-medium text-gray-600">Gambar</th>
<th class="border-b border-gray-200 px-4 py-2 text-left font-medium text-gray-600">Nama Mobil</th>
<th class="border-b border-gray-200 px-4 py-2 text-left font-medium text-gray-600">Sub Kriteria</th>
<th class="border-b border-gray-200 px-4 py-2 text-left font-medium text-gray-600">Kelengkapan</th>
<th class="border-b border-gray-200 px-4 py-2 text-left font-medium text-gray-600">Harga Sewa / Hari</th>
<th class="border-b border-gray-200 px-4 py-2 text-left font-medium text-gray-600">Konsumsi BBM</th>
<th class="border-b border-gray-200 px-4 py-2 text-left font-medium text-gray-600">Tahun</th>
<th class="border-b border-gray-200 px-4 py-2 text-left font-medium text-gray-600">Aksi</th>
</tr>
</thead>
<tbody>
@forelse ($mobils as $mobil)
<tr class="hover:bg-gray-50 transition-colors duration-150">
<td class="border-b border-gray-100 px-4 py-3">{{ $loop->iteration }}</td>
<td class="border-b border-gray-100 px-4 py-3">
@if($mobil->gambar)
<img src="{{ asset('assets/images/' . $mobil->gambar) }}" alt="Gambar Mobil" class="w-20 h-12 object-contain rounded" />
@else
<span class="text-gray-400 italic text-xs">Tidak ada gambar</span>
@endif
</td>
<td class="border-b border-gray-100 px-4 py-3">{{ $mobil->nama_mobil }}</td>
<td class="border-b border-gray-100 px-4 py-3">{{ $mobil->subkriteria->nama_subkriteria ?? '-' }}</td>
<td class="border-b border-gray-100 px-4 py-3">{{ $mobil->kelengkapan_mobil ?? '-' }}</td>
<td class="border-b border-gray-100 px-4 py-3">{{ $mobil->harga_sewa_per_hari ?? '-' }}</td>
<td class="border-b border-gray-100 px-4 py-3">{{ $mobil->konsumsi_bbm ?? '-' }}</td>
<td class="border-b border-gray-100 px-4 py-3">{{ $mobil->tahun ?? '-' }}</td>
<td class="border-b border-gray-100 px-4 py-3 flex space-x-4">
<a href="{{ route('mobil.edit', $mobil->id) }}" class="text-[#1e3a8a] hover:text-[#163570]" title="Edit">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.232 5.232l3.536 3.536M9 11l6 6m-8 2v-3a1 1 0 011-1h3m10-3a2 2 0 11-4 0 2 2 0 014 0z" />
</svg>
</a>
<form action="{{ route('mobil.destroy', $mobil->id) }}" method="POST" class="inline" onsubmit="return confirm('Yakin ingin menghapus data ini?');">
@csrf
@method('DELETE')
<button type="submit" class="text-red-600 hover:text-red-800 p-0 m-0 border-0 bg-transparent" title="Hapus">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5-4h4m-4 0a2 2 0 00-2 2v2h8V5a2 2 0 00-2-2m-4 0h4" />
</svg>
</button>
</form>
</td>
</tr>
@empty
<tr>
<td colspan="9" class="text-center py-6 text-gray-400 italic">Belum ada data mobil.</td>
</tr>
@endforelse
</tbody>
</table>
<div class="mt-6">
{{ $mobils->links() }}
</div>
</div>
@endsection