MIF_E31222663/resources/views/admin/data-latih/index.blade.php

115 lines
4.8 KiB
PHP

@extends('layouts.app')
@section('title', 'Dataset - ISPA Prediction')
@section('content')
{{-- Notifikasi sukses --}}
@if(session('success'))
<div class="alert alert-success alert-dismissible fade show" role="alert">
{{ session('success') }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
@endif
{{-- Notifikasi error --}}
@if(session('error'))
<div class="alert alert-danger alert-dismissible fade show" role="alert">
{{ session('error') }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
@endif
{{-- Notifikasi validasi --}}
@if ($errors->any())
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<ul class="mb-0">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
@endif
<div class="container">
<h2 class="mb-4">Dataset</h2>
<div class="card">
<div class="card-body">
<!-- Form Pencarian -->
<form method="GET" action="{{ route('data-latih.index') }}">
<div class="input-group">
<input type="text" class="form-control" name="search" value="{{ request()->get('search') }}" placeholder="Cari Dataset...">
<button class="btn btn-primary" type="submit">Cari</button>
</div>
</form>
<hr>
<div class="d-flex justify-content-between mb-3">
<!-- Form Import Excel -->
<form action="{{ route('import.excel') }}" method="POST" enctype="multipart/form-data" class="d-flex">
@csrf
<input type="file" name="file" class="form-control me-2" required>
<button type="submit" class="btn btn-success me-2">Import Excel</button>
</form>
<!-- Form Hapus Semua Data -->
<form action="{{ route('data-latih.destroyAll') }}" method="POST" onsubmit="return confirm('Apakah Anda yakin ingin menghapus semua data?')">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Hapus Semua Data</button>
</form>
</div>
<table class="table table-striped">
<thead>
<tr>
<th>No</th>
<th>Kecamatan</th>
<th>Data Tahun</th>
<th>Perilaku Hidup Bersih dan Sehat</th>
<th>Imunisasi PCV</th>
<th>Kebiasaan Merokok Orang Tua</th>
<th>Kasus</th>
<th>Latitude</th>
<th>Longitude</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@forelse ($data_latih as $index => $data)
<tr>
<td>{{ $data_latih->firstItem() + $index }}</td>
<td>{{ $data->kecamatan }}</td>
<td>{{ $data->data_tahun }}</td>
<td>{{ $data->phbs }}</td>
<td>{{ $data->imunisasi }}</td>
<td>{{ $data->merokok }}</td>
<td>{{ $data->kasus_2023 }}</td>
<td>{{ $data->latitude }}</td>
<td>{{ $data->longitude }}</td>
<td>{{ $data->hipotesis }}</td>
<td>
<div class="d-inline-flex gap-1">
<a href="{{ route('edit', $data->id) }}" class="btn btn-sm btn-primary">Edit</a>
<form action="{{ route('delete', $data->id) }}" method="POST">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('Yakin ingin menghapus data ini?')">Delete</button>
</form>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="14" class="text-center">Tidak ada dataset</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
<!-- Pagination Links -->
<div class="d-flex justify-content-center mt-4">
{{ $data_latih->withQueryString()->links('pagination::bootstrap-5') }}
</div>
@endsection