MIF_E31222629/resources/views/nilai-alternatif/index.blade.php

89 lines
5.1 KiB
PHP

<!-- resources/views/nilai-alternatif/index.blade.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 Nilai Alternatif</h1>
<a href="{{ route('nilai-alternatif.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 Nilai
</a>
</div>
<form action="{{ route('nilai-alternatif.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 nilai alternatif...">
<button type="submit"
class="bg-[#1e3a8a] text-white px-4 py-2 rounded hover:bg-[#163570] transition text-sm">
Cari
</button>
</form>
@if(session('success'))
<p class="mb-4 text-green-600">{{ session('success') }}</p>
@endif
@if($nilaiAlternatifs->count())
<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">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">Nilai</th>
<th class="border-b border-gray-200 px-4 py-2 text-left font-medium text-gray-600">Aksi</th>
</tr>
</thead>
<tbody>
@foreach($nilaiAlternatifs as $nilai)
<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">{{ $nilai->mobil->nama_mobil }}</td>
<td class="border-b border-gray-100 px-4 py-3">{{ $nilai->subkriteria->nama_subkriteria }}</td>
<td class="border-b border-gray-100 px-4 py-3">{{ $nilai->nilai }}</td>
<td class="border-b border-gray-100 px-4 py-3 flex space-x-4">
<!-- Edit Icon only, with hover text -->
<a href="{{ route('nilai-alternatif.edit', $nilai->id) }}"
class="relative text-[#1e3a8a] hover:text-[#163570]" title="Edit">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M11 5H6a2 2 0 00-2 2v12a2 2 0 002 2h12a2 2 0 002-2v-5m-10-7l8 8m-3 0h3v3" />
</svg>
<span
class="absolute left-full ml-2 top-1/2 -translate-y-1/2 whitespace-nowrap rounded bg-gray-700 px-2 py-1 text-xs text-white opacity-0 transition-opacity group-hover:opacity-100 pointer-events-none">
Edit
</span>
</a>
<!-- Delete Icon only, with hover text -->
<form action="{{ route('nilai-alternatif.destroy', $nilai->id) }}" method="POST" onsubmit="return confirm('Yakin ingin menghapus data ini?');" class="relative">
@csrf
@method('DELETE')
<button type="submit" class="text-red-600 hover:text-red-800 bg-transparent p-0" title="Hapus">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" 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>
<span
class="absolute left-full ml-2 top-1/2 -translate-y-1/2 whitespace-nowrap rounded bg-gray-700 px-2 py-1 text-xs text-white opacity-0 transition-opacity group-hover:opacity-100 pointer-events-none">
Hapus
</span>
</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
<div class="mt-6">
{{ $nilaiAlternatifs->links() }}
</div>
@else
<p class="text-center py-6 text-gray-400 italic">Belum ada data nilai alternatif.</p>
@endif
</div>
@endsection