113 lines
5.5 KiB
PHP
113 lines
5.5 KiB
PHP
@extends('layout.main')
|
|
|
|
@section('content')
|
|
<div class="container-xxl flex-grow-1 container-p-y">
|
|
<div class="card">
|
|
<div class="card-body border-bottom">
|
|
<form method="GET" action="{{ route('tabel.index') }}" class="d-flex justify-content-between align-items-center row gap-3 gap-md-0">
|
|
<div class="col-md-auto">
|
|
<div class="d-flex align-items-center">
|
|
<label class="me-2 text-nowrap">Show</label>
|
|
<select name="per_page" class="form-select form-select-sm w-auto" onchange="this.form.submit()">
|
|
<option value="10" {{ request('per_page') == 10 ? 'selected' : '' }}>10</option>
|
|
<option value="25" {{ request('per_page') == 25 ? 'selected' : '' }}>25</option>
|
|
<option value="50" {{ request('per_page') == 50 ? 'selected' : '' }}>50</option>
|
|
</select>
|
|
<label class="ms-2 text-nowrap">entries</label>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-auto d-flex gap-2">
|
|
<div class="input-group input-group-sm w-auto">
|
|
<input type="text" name="search" class="form-control" placeholder="Cari Nama Petani..." value="{{ request('search') }}">
|
|
<button type="submit" class="btn btn-outline-primary"><i class="ti tabler-search"></i></button>
|
|
</div>
|
|
<a href="{{ route('petani-cpm.create') }}" class="btn btn-sm btn-primary">
|
|
<i class="ti tabler-plus me-1"></i> Tambah
|
|
</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="table-responsive text-nowrap">
|
|
<table class="table table-hover">
|
|
<thead class="border-top">
|
|
<tr>
|
|
<th>No</th>
|
|
<th>Nama Petani</th>
|
|
<th>Jenis Kelamin</th>
|
|
<th>Usia</th>
|
|
<th>Desa/Kelurahan</th>
|
|
<th>Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@forelse($petani as $p)
|
|
<tr>
|
|
<td>{{ $loop->iteration }}</td>
|
|
<td><span class="text-heading">{{ $p->nama }}</span></td>
|
|
<td><span class="text-muted">{{ $p->jenis_kelamin ? 'Laki-laki' : 'Perempuan' }}</span></td>
|
|
<td><span class="text-muted">{{ $p->umur }} tahun</span></td>
|
|
<td><span class="text-muted">{{ $p->desaKelurahan->nama }}, {{ $p->desaKelurahan->kecamatan->nama }}, {{ $p->desaKelurahan->kecamatan->kabupatenKota->nama }}, {{ $p->desaKelurahan->kecamatan->kabupatenKota->provinsi->nama }}</span></td>
|
|
<td>
|
|
<div class="d-flex align-items-center">
|
|
<a href="{{ route('petani-cpm.edit', $p->id) }}" class="btn btn-icon btn-text-secondary rounded-pill edit-record"><i class="ti tabler-edit ti-md"></i></a>
|
|
<a href="javascript:;" class="btn btn-icon btn-text-secondary rounded-pill delete-record" data-id="{{ $p->id }}" data-nama="{{ $p->nama }}"><i class="ti tabler-trash ti-md"></i></a>
|
|
<a href="{{ route('petani-cpm.show', $p->id) }}" class="btn btn-icon btn-text-secondary rounded-pill view-record"><i class="ti tabler-eye ti-md"></i></a>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="6" class="text-center py-4">Tidak ada data ditemukan.</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="card-footer d-flex justify-content-center justify-content-md-end border-top">
|
|
{{ $petani->appends(request()->query())->links('pagination::bootstrap-5') }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|
|
|
|
@push('scripts')
|
|
<script>
|
|
'use strict';
|
|
|
|
$(document).ready(function () {
|
|
|
|
$(".delete-record").click(function (e) {
|
|
e.preventDefault();
|
|
const id = $(this).data('id');
|
|
const name = $(this).data('nama');
|
|
|
|
Swal.fire({
|
|
title: 'Hapus?',
|
|
text: `Kolom ${name} akan dihapus!`,
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonText: 'Ya, Hapus!',
|
|
customClass: { confirmButton: 'btn btn-danger me-3', cancelButton: 'btn btn-label-secondary' },
|
|
buttonsStyling: false
|
|
}).then(function (result) {
|
|
if (result.value) {
|
|
$.ajax({
|
|
url: "{{ route('petani-cpm.destroy', ':id') }}".replace(':id', id),
|
|
type: 'POST',
|
|
data: {
|
|
_token: '{{ csrf_token() }}',
|
|
_method: 'DELETE'
|
|
},
|
|
success: function () {
|
|
Swal.fire({ icon: 'success', title: 'Terhapus!', showConfirmButton: false, timer: 1500 })
|
|
.then(() => location.reload());
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
@endpush |