172 lines
8.6 KiB
PHP
172 lines
8.6 KiB
PHP
@extends('layout.app')
|
|
@section('content')
|
|
<div class="container">
|
|
<div class="page-inner">
|
|
<div class="page-header">
|
|
<h3 class="fw-bold mb-3">Data Gejala</h3>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<a href="#" data-bs-toggle="modal" data-bs-target="#addModal"
|
|
class="btn btn-primary btn-icon-split mb-3">
|
|
<span class="icon text-white-50"><i class="fas fa-plus"></i></span>
|
|
<span class="text">Tambah Gejala</span>
|
|
</a>
|
|
<table id="basic-datatables" class="display table table-striped table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th style="width: 5%;" class="text-center">No</th>
|
|
<th style="width: 5%;">Kode</th>
|
|
<th style="width: 70%;">Nama Gejala</th>
|
|
<th style="width: 20%;" class="text-center">Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
<tfoot>
|
|
<tr>
|
|
<th style="width: 5%;" class="text-center">No</th>
|
|
<th style="width: 5%;">Kode</th>
|
|
<th style="width: 70%;">Nama Gejala</th>
|
|
<th style="width: 20%;" class="text-center">Aksi</th>
|
|
</tr>
|
|
</tfoot>
|
|
<tbody>
|
|
@foreach ($gejala as $item)
|
|
<tr>
|
|
<td class="text-center">{{ $loop->iteration }}</td>
|
|
<td>{{ $item->kode_gejala }}</td>
|
|
<td>{{ $item->gejala }}</td>
|
|
<td class="text-center">
|
|
<a href="#" data-bs-toggle="modal" data-bs-target="#updateModal"
|
|
class="btn btn-warning mb-3"
|
|
onclick="updateData({{ $item }})">
|
|
<i class="fas fa-edit"></i>
|
|
</a>
|
|
<a class="btn btn-danger mb-3" href="#" data-bs-toggle="modal"
|
|
data-bs-target="#deleteModal"
|
|
onclick="deleteData({{ $item->id }})">
|
|
<i class="fas fa-trash"></i>
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="modal fade" id="addModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="exampleModalLabel">Tambah Gejala</h5>
|
|
<button class="btn-close" type="button" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form action="{{ route('gejala.store') }}" method="POST" id="addForm" enctype="multipart/form-data">
|
|
@csrf
|
|
<div class="mb-3">
|
|
<label for="addGejala" class="form-label" style="font-weight: bold">Gejala</label>
|
|
<input type="text" class="form-control" id="addGejala" name="gejala"
|
|
placeholder="Enter Nama Gejala" value="{{ old('gejala') }}" required>
|
|
@error('gejala')
|
|
<small class="text-danger">{{ $message }}</small>
|
|
@enderror
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button class="btn btn-danger" type="button" data-bs-dismiss="modal">Batal</button>
|
|
<button class="btn btn-primary" type="submit" form="addForm">Simpan</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal fade" id="updateModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="exampleModalLabel">Edit Gejala</h5>
|
|
<button class="btn-close" type="button" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form action="{{ route('gejala.update', ':id') }}" method="POST" id="updateForm"
|
|
enctype="multipart/form-data">
|
|
@csrf
|
|
@method('PUT')
|
|
<div class="mb-3">
|
|
<label for="updateGejala" class="form-label" style="font-weight: bold">Gejala</label>
|
|
<input type="text" class="form-control" id="updateGejala" name="gejala"
|
|
placeholder="Enter Nama Gejala" value="{{ old('gejala') }}" required>
|
|
@error('gejala')
|
|
<small class="text-danger">{{ $message }}</small>
|
|
@enderror
|
|
</div>
|
|
</form>
|
|
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button class="btn btn-danger" type="button" data-bs-dismiss="modal">Batal</button>
|
|
<button class="btn btn-primary" type="submit" form="updateForm">Edit</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="deleteModalLabel">Hapus Gejala</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<p>Apakah Anda yakin ingin menghapus data gejala ini?</p>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
|
|
<form id="deleteForm" action="" method="POST" style="display: inline;">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit" class="btn btn-danger">Hapus</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|
|
|
|
|
|
|
|
@section('script')
|
|
<script>
|
|
$(document).ready(function() {
|
|
$("#basic-datatables").DataTable({});
|
|
});
|
|
|
|
function updateData(data) {
|
|
const form = document.getElementById('updateForm');
|
|
form.action = "{{ route('gejala.update', ':id') }}".replace(':id', data.id);
|
|
form.querySelector('#updateGejala').value = data.gejala;
|
|
}
|
|
|
|
function deleteData(id) {
|
|
const form = document.getElementById('deleteForm');
|
|
form.action = "{{ route('gejala.destroy', ':id') }}".replace(':id', id);
|
|
}
|
|
</script>
|
|
@endsection
|