fixing crud
This commit is contained in:
parent
3968728dee
commit
79e43efa01
|
@ -35,7 +35,15 @@ public function create()
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
//
|
$validatedData = $request->validate([
|
||||||
|
'kode_penyakit' => 'required|string',
|
||||||
|
'kode_gejala' => 'required|string',
|
||||||
|
|
||||||
|
]);
|
||||||
|
|
||||||
|
Penyakit::create($validatedData);
|
||||||
|
|
||||||
|
return redirect('penyakit')->with('success', 'Data gejala berhasil disimpan.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,9 +65,22 @@ public function edit(string $id)
|
||||||
/**
|
/**
|
||||||
* Update the specified resource in storage.
|
* Update the specified resource in storage.
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, string $id)
|
public function update(Request $request, string $id_aturan)
|
||||||
{
|
{
|
||||||
//
|
$validatedData = $request->validate([
|
||||||
|
'kode_penyakit' => 'required|string|max:255',
|
||||||
|
'kode_gejala' => 'required|string|max:255', // Foto produk menjadi opsional untuk diubah
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Dapatkan data produk berdasarkan ID
|
||||||
|
$aturan = Aturan::findOrFail($id_aturan);
|
||||||
|
|
||||||
|
// Perbarui data produk
|
||||||
|
$aturan->kode_penyakit = $validatedData['kode_penyakit'];
|
||||||
|
$aturan->kode_gejala = $validatedData['kode_gejala'];
|
||||||
|
|
||||||
|
$aturan->save();
|
||||||
|
return redirect()->route('aturan')->with('success', 'Produk berhasil diperbarui.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,16 +32,29 @@ public function create()
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
$validatedData = $request->validate([
|
$validatedData = $request->validate([
|
||||||
'kode_gejala' => 'required|string',
|
'kode_gejala' => 'required|string',
|
||||||
'gejala' => 'required|string',
|
'gejala' => 'required|string',
|
||||||
'nilai_densitas' => 'required|string',
|
'nilai_densitas' => 'required|string',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Gejala::create($validatedData);
|
// Buat objek Gejala baru
|
||||||
|
$gejala = new Gejala();
|
||||||
|
$gejala->kode_gejala = $validatedData['kode_gejala'];
|
||||||
|
$gejala->gejala = $validatedData['gejala'];
|
||||||
|
$gejala->nilai_densitas = $validatedData['nilai_densitas'];
|
||||||
|
|
||||||
return redirect('gejala')->with('success', 'Data gejala berhasil disimpan.');
|
// Simpan objek Gejala ke dalam database
|
||||||
|
$gejala->save();
|
||||||
|
|
||||||
|
// Redirect kembali ke halaman yang sesuai
|
||||||
|
return redirect('gejala')->with('success', 'Gejala berhasil ditambahkan!');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Tangkap pengecualian dan tampilkan pesan kesalahan
|
||||||
|
return redirect('home')->withInput()->withErrors(['error' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,9 +76,24 @@ public function edit(string $id)
|
||||||
/**
|
/**
|
||||||
* Update the specified resource in storage.
|
* Update the specified resource in storage.
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, string $id)
|
public function update(Request $request, string $id_gejala)
|
||||||
{
|
{
|
||||||
//
|
$validatedData = $request->validate([
|
||||||
|
'kode_gejala' => 'required|string|max:255',
|
||||||
|
'gejala' => 'required|string|max:255', // Foto produk menjadi opsional untuk diubah
|
||||||
|
'nilai_densitas' => 'required|string|max:255',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Dapatkan data produk berdasarkan ID
|
||||||
|
$gejala = Gejala::findOrFail($id_gejala);
|
||||||
|
|
||||||
|
// Perbarui data produk
|
||||||
|
$gejala->kode_gejala = $validatedData['kode_gejala'];
|
||||||
|
$gejala->gejala = $validatedData['gejala'];
|
||||||
|
$gejala->nilai_densitas = $validatedData['nilai_densitas'];
|
||||||
|
|
||||||
|
$gejala->save();
|
||||||
|
return redirect()->route('gejala')->with('success', 'Produk berhasil diperbarui.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,7 +34,16 @@ public function create()
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
//
|
$validatedData = $request->validate([
|
||||||
|
'kode_penyakit' => 'required|string',
|
||||||
|
'nama_penyakit' => 'required|string',
|
||||||
|
'deskripsi_penyakit' => 'required|string',
|
||||||
|
'solusi' => 'required|string',
|
||||||
|
]);
|
||||||
|
|
||||||
|
Penyakit::create($validatedData);
|
||||||
|
|
||||||
|
return redirect('penyakit')->with('success', 'Data gejala berhasil disimpan.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,9 +65,26 @@ public function edit(string $id)
|
||||||
/**
|
/**
|
||||||
* Update the specified resource in storage.
|
* Update the specified resource in storage.
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, string $id)
|
public function update(Request $request, string $id_penyakit)
|
||||||
{
|
{
|
||||||
//
|
$validatedData = $request->validate([
|
||||||
|
'kode_penyakit' => 'required|string|max:255',
|
||||||
|
'nama_penyakit' => 'required|string|max:255', // Foto produk menjadi opsional untuk diubah
|
||||||
|
'deskripsi_penyakit' => 'required|string|max:255',
|
||||||
|
'solusi' => 'required|string|max:255',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Dapatkan data produk berdasarkan ID
|
||||||
|
$penyakit = Penyakit::findOrFail($id_penyakit);
|
||||||
|
|
||||||
|
// Perbarui data produk
|
||||||
|
$penyakit->kode_penyakit = $validatedData['kode_penyakit'];
|
||||||
|
$penyakit->nama_penyakit = $validatedData['nama_penyakit'];
|
||||||
|
$penyakit->deskripsi_penyakit = $validatedData['deskripsi_penyakit'];
|
||||||
|
$penyakit->solusi = $validatedData['solusi'];
|
||||||
|
|
||||||
|
$penyakit->save();
|
||||||
|
return redirect()->route('penyakit')->with('success', 'Penyakit berhasil diperbarui.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
class Penyakit extends Model
|
class Penyakit extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
public $timestamps = false;
|
||||||
protected $table="penyakit";
|
protected $table="penyakit";
|
||||||
protected $primaryKey="id_penyakit";
|
protected $primaryKey="id_penyakit";
|
||||||
|
protected $fillable=["kode_penyakit","nama_penyakit","deskripsi_penyakit","solusi"];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,11 +111,11 @@ class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100
|
||||||
|
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
{{-- <a href="#" class="edit-button" data-bs-toggle="modal" data-bs-target="#edit-gejala"
|
<a href="#" class="edit-button" data-bs-toggle="modal" data-bs-target="#edit-aturan"
|
||||||
data-id_gejala="{{ $data->id_aturan }}" data-kode-gejala="{{ $data->kode_gejala }}"
|
data-id_aturan="{{ $data->id_aturan }}" data-kode_penyakit="{{ $data->kode_penyakit }}"
|
||||||
data-gejala="{{ $data->gejala }}" data-nilai-densitas="{{ $data->nilai_densitas}}">
|
data-kode_gejala="{{ $data->kode_gejala }}">
|
||||||
<i class="fas fa-edit"></i>
|
<i class="fas fa-edit"></i>
|
||||||
</a> --}}
|
</a>
|
||||||
<a href="{{ route('delete-aturan', $data->id_aturan) }}" onclick="return confirm('Apakah Anda yakin ingin menghapus produk ini?')">
|
<a href="{{ route('delete-aturan', $data->id_aturan) }}" onclick="return confirm('Apakah Anda yakin ingin menghapus produk ini?')">
|
||||||
<i class="fas fa-trash-alt" style="color: red"></i>
|
<i class="fas fa-trash-alt" style="color: red"></i>
|
||||||
</a>
|
</a>
|
||||||
|
@ -124,9 +124,9 @@ class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
{{-- @include('dashboard.produk.edit-produk') --}}
|
@include('dashboard.aturan.edit-aturan')
|
||||||
|
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
{{-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('.edit-button').click(function() {
|
$('.edit-button').click(function() {
|
||||||
|
@ -136,14 +136,14 @@ class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100
|
||||||
var harga = $(this).data('harga');
|
var harga = $(this).data('harga');
|
||||||
var stok = $(this).data('stok');
|
var stok = $(this).data('stok');
|
||||||
|
|
||||||
$('#edit-produk').find('#edit-id').val(id_produk);
|
$('#edit-aturan').find('#edit-id').val(id_aturan);
|
||||||
$('#edit-produk').find('#edit-nama').val(nama);
|
$('#edit-aturan').find('#edit-nama').val(nama);
|
||||||
$('#edit-produk').find('#edit-foto').val(foto);
|
$('#edit-aturan').find('#edit-foto').val(foto);
|
||||||
$('#edit-produk').find('#edit-harga').val(harga);
|
$('#edit-aturan').find('#edit-harga').val(harga);
|
||||||
$('#edit-produk').find('#edit-stok').val(stok);
|
$('#edit-aturan').find('#edit-stok').val(stok);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script> --}}
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
<!-- Modal Edit Data -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('.edit-button').on('click', function(event) {
|
||||||
|
var id_aturan = $(this).data('id_aturan');
|
||||||
|
var kode_penyakit = $(this).data('kode_penyakit');
|
||||||
|
var kode_gejala = $(this).data('kode_gejala');
|
||||||
|
|
||||||
|
|
||||||
|
var modal = $('#edit-aturan');
|
||||||
|
modal.find('.modal-body #id_aturan').val(id_aturan);
|
||||||
|
modal.find('.modal-body #kode_penyakit').val(kode_penyakit);
|
||||||
|
modal.find('.modal-body #kode_gejala').val(kode_gejala);
|
||||||
|
// modal.find('.modal-body #foto_produk').val(foto_produk); // Ini tidak bisa di-set secara langsung karena input tipe file
|
||||||
|
|
||||||
|
|
||||||
|
modal.modal('show');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="modal fade" id="edit-aturan" tabindex="-1" role="dialog" aria-labelledby="editUserModalLabel"
|
||||||
|
aria-hidden="true">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="editUserModalLabel">Edit Aturan</h5>
|
||||||
|
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<!-- Form for editing user data -->
|
||||||
|
@if ($data->count() == 0)
|
||||||
|
<p>data kosong</p>
|
||||||
|
@else
|
||||||
|
<form action="{{route('update-aturan',$data->id_aturan)}}" method="POST" enctype="multipart/form-data">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
<div class="form-group" @style('display:none;')>
|
||||||
|
<label for="edit-id_aturan">Name</label>
|
||||||
|
<input type="text" name="id_aturan" class="form-control" id="id_aturan" placeholder="Enter name">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="edit-kode_penyakit">Kode penyakit</label>
|
||||||
|
<input type="text" name="kode_penyakit" class="form-control" id="kode_penyakit" placeholder="Enter name">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="edit-gejala">Kode Gejala </label>
|
||||||
|
<input type="text" name="kode_gejala" class="form-control" id="kode_gejala" placeholder="Enter email">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Tombol Submit untuk mengirimkan formulir -->
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="modal fade" id="add-produk" tabindex="-1" role="dialog" aria-labelledby="editUserModalLabel"
|
<div class="modal fade" id="add-gejala" tabindex="-1" role="dialog" aria-labelledby="editUserModalLabel"
|
||||||
aria-hidden="true">
|
aria-hidden="true">
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
@ -9,19 +9,18 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<form action="{{ route('add-gejala') }}" class="needs-validation" novalidate="" method="POST" enctype="multipart/form-data">
|
<form action="{{ route('add-gejala') }}" class="needs-validation" novalidate="" method="POST">
|
||||||
@csrf
|
@csrf
|
||||||
@method('POST')
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="edit-name">Kode Gejala</label>
|
<label for="edit-kode_gejala">Kode Gejala</label>
|
||||||
<input type="text" name="kode_gejala" class="form-control" placeholder="Masukkan Kode Gejala">
|
<input type="text" name="kode_gejala" class="form-control" placeholder="Masukkan Kode Gejala">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="edit-email">Gejala</label>
|
<label for="edit-gejala">Gejala</label>
|
||||||
<input type="text" name="gejala" class="form-control" placeholder="Masukkan Gejala">
|
<input type="text" name="gejala" class="form-control" placeholder="Masukkan Gejala">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="edit-area">Nilai Densitas</label>
|
<label for="edit-nilai_densitas">Nilai Densitas</label>
|
||||||
<input type="text" name="nilai_densitas" class="form-control" placeholder="Masukkan Nilai Densitas">
|
<input type="text" name="nilai_densitas" class="form-control" placeholder="Masukkan Nilai Densitas">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
<!-- Modal Edit Data -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('.edit-button').on('click', function(event) {
|
||||||
|
var id_gejala = $(this).data('id_gejala');
|
||||||
|
var kode_gejala = $(this).data('kode_gejala');
|
||||||
|
var gejala = $(this).data('gejala');
|
||||||
|
var nilai_densitas = $(this).data('nilai_densitas');
|
||||||
|
|
||||||
|
var modal = $('#edit-gejala');
|
||||||
|
modal.find('.modal-body #id_gejala').val(id_gejala);
|
||||||
|
modal.find('.modal-body #kode_gejala').val(kode_gejala);
|
||||||
|
modal.find('.modal-body #gejala').val(gejala);
|
||||||
|
// modal.find('.modal-body #foto_produk').val(foto_produk); // Ini tidak bisa di-set secara langsung karena input tipe file
|
||||||
|
modal.find('.modal-body #nilai_densitas').val(nilai_densitas);
|
||||||
|
|
||||||
|
modal.modal('show');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="modal fade" id="edit-gejala" tabindex="-1" role="dialog" aria-labelledby="editUserModalLabel"
|
||||||
|
aria-hidden="true">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="editUserModalLabel">Edit Gejala</h5>
|
||||||
|
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<!-- Form for editing user data -->
|
||||||
|
@if ($data->count() == 0)
|
||||||
|
<p>data kosong</p>
|
||||||
|
@else
|
||||||
|
<form action="{{route('update-gejala',$data->id_gejala)}}" method="POST" enctype="multipart/form-data">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
<div class="form-group" @style('display:none;')>
|
||||||
|
<label for="edit-id_gejala">Name</label>
|
||||||
|
<input type="text" name="id_gejala" class="form-control" id="id_gejala" placeholder="Enter name">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="edit-kode_gejala">Kode Gejala</label>
|
||||||
|
<input type="text" name="kode_gejala" class="form-control" id="kode_gejala" placeholder="Enter name">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="edit-gejala">Gejala</label>
|
||||||
|
<input type="text" name="gejala" class="form-control" id="gejala" placeholder="Enter email">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="edit-harga">Nilai Densitas</label>
|
||||||
|
<input type="text" name="nilai_densitas" class="form-control" id="nilai_densitas" placeholder="Enter harga">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Tombol Submit untuk mengirimkan formulir -->
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -82,7 +82,7 @@ class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100
|
||||||
<h6 class="m-0 font-weight-bold text-primary">Data Gejala</h6>
|
<h6 class="m-0 font-weight-bold text-primary">Data Gejala</h6>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-header py-3">
|
<div class="card-header py-3">
|
||||||
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#add-produk">Tambah Gejala</button>
|
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#add-gejala">Tambah Gejala</button>
|
||||||
@include('dashboard.gejala.add-gejala')
|
@include('dashboard.gejala.add-gejala')
|
||||||
{{-- @include('dashboard.produk.add-produk-to-admin') --}}
|
{{-- @include('dashboard.produk.add-produk-to-admin') --}}
|
||||||
</div>
|
</div>
|
||||||
|
@ -112,8 +112,8 @@ class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<a href="#" class="edit-button" data-bs-toggle="modal" data-bs-target="#edit-gejala"
|
<a href="#" class="edit-button" data-bs-toggle="modal" data-bs-target="#edit-gejala"
|
||||||
data-id_gejala="{{ $data->id_gejala }}" data-kode-gejala="{{ $data->kode_gejala }}"
|
data-id_gejala="{{ $data->id_gejala }}" data-kode_gejala="{{ $data->kode_gejala }}"
|
||||||
data-gejala="{{ $data->gejala }}" data-nilai-densitas="{{ $data->nilai_densitas}}">
|
data-gejala="{{ $data->gejala }}" data-nilai_densitas="{{ $data->nilai_densitas}}">
|
||||||
<i class="fas fa-edit"></i>
|
<i class="fas fa-edit"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="{{ route('delete-gejala', $data->id_gejala) }}" onclick="return confirm('Apakah Anda yakin ingin menghapus produk ini?')">
|
<a href="{{ route('delete-gejala', $data->id_gejala) }}" onclick="return confirm('Apakah Anda yakin ingin menghapus produk ini?')">
|
||||||
|
@ -123,24 +123,23 @@ class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@include('dashboard.gejala.edit-gejala')
|
||||||
{{-- @include('dashboard.produk.edit-produk') --}}
|
|
||||||
|
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('.edit-button').click(function() {
|
$('.edit-button').click(function() {
|
||||||
var id_produk = $(this).data('id_produk');
|
var id_gejala = $(this).data('id_gejala');
|
||||||
var nama = $(this).data('nama');
|
var kode_gejala = $(this).data('kode_gejala');
|
||||||
var foto = $(this).data('foto');
|
var gejala = $(this).data('gejala');
|
||||||
var harga = $(this).data('harga');
|
var nilai_densitas = $(this).data('nilai_densitas');
|
||||||
var stok = $(this).data('stok');
|
|
||||||
|
|
||||||
|
$('#edit-gejala').find('#edit-id_gejala').val(id_gejala);
|
||||||
|
$('#edit-gejala').find('#edit-kode_gejala').val(kode_gejala);
|
||||||
|
$('#edit-gejala').find('#edit-gejala').val(gejala);
|
||||||
|
$('#edit-gejala').find('#edit-nilai_densitas').val(nilai_densitas);
|
||||||
|
|
||||||
$('#edit-produk').find('#edit-id').val(id_produk);
|
|
||||||
$('#edit-produk').find('#edit-nama').val(nama);
|
|
||||||
$('#edit-produk').find('#edit-foto').val(foto);
|
|
||||||
$('#edit-produk').find('#edit-harga').val(harga);
|
|
||||||
$('#edit-produk').find('#edit-stok').val(stok);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -161,6 +160,15 @@ class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
|
||||||
|
|
||||||
<!-- Modal Add Data -->
|
<!-- Modal Add Data -->
|
||||||
|
@if ($errors->any())
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<ul>
|
||||||
|
@foreach ($errors->all() as $error)
|
||||||
|
<li>{{ $error }}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
<div class="modal fade" id="add-gejala" tabindex="-1" role="dialog" aria-labelledby="addGejalaModalLabel"
|
<div class="modal fade" id="add-gejala" tabindex="-1" role="dialog" aria-labelledby="addGejalaModalLabel"
|
||||||
aria-hidden="true">
|
aria-hidden="true">
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<form action="{{ route('add-gejala') }}" class="needs-validation" novalidate="" method="POST" enctype="multipart/form-data">
|
<form action="{{ route('add-penyakit') }}" class="needs-validation" novalidate="" method="POST" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
@method('POST')
|
@method('POST')
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="edit-email">Nama Penyakit</label>
|
<label for="edit-email">Nama Penyakit</label>
|
||||||
<input type="text" name="gejala" class="form-control" placeholder="Masukkan Nama Penyakit">
|
<input type="text" name="nama_penyakit" class="form-control" placeholder="Masukkan Nama Penyakit">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="edit-area">Deskripsi Penyakit</label>
|
<label for="edit-area">Deskripsi Penyakit</label>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="edit-area">Solusi</label>
|
<label for="edit-area">Solusi</label>
|
||||||
<input type="text" name="Solusi" class="form-control" placeholder="Masukkan Solusi">
|
<input type="text" name="solusi" class="form-control" placeholder="Masukkan Solusi">
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
<!-- Modal Edit Data -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('.edit-button').on('click', function(event) {
|
||||||
|
var id_penyakit = $(this).data('id_penyakit');
|
||||||
|
var kode_penyakit = $(this).data('kode_penyakit');
|
||||||
|
var nama_penyakit = $(this).data('nama_penyakit');
|
||||||
|
var deskripsi_penyakit = $(this).data('deskripsi_penyakit');
|
||||||
|
var solusi = $(this).data('solusi');
|
||||||
|
|
||||||
|
var modal = $('#edit-penyakit');
|
||||||
|
modal.find('.modal-body #id_penyakit').val(id_penyakit);
|
||||||
|
modal.find('.modal-body #nama_penyakit').val(nama_penyakit);
|
||||||
|
modal.find('.modal-body #kode_penyakit').val(kode_penyakit);
|
||||||
|
modal.find('.modal-body #deskripsi_penyakit').val(deskripsi_penyakit);
|
||||||
|
modal.find('.modal-body #solusi').val(solusi);
|
||||||
|
// modal.find('.modal-body #foto_produk').val(foto_produk); // Ini tidak bisa di-set secara langsung karena input tipe file
|
||||||
|
|
||||||
|
|
||||||
|
modal.modal('show');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="modal fade" id="edit-penyakit" tabindex="-1" role="dialog" aria-labelledby="editUserModalLabel"
|
||||||
|
aria-hidden="true">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="editUserModalLabel">Edit Penyakit</h5>
|
||||||
|
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<!-- Form for editing user data -->
|
||||||
|
@if ($data->count() == 0)
|
||||||
|
<p>data kosong</p>
|
||||||
|
@else
|
||||||
|
<form action="{{route('update-penyakit',$data->id_penyakit)}}" method="POST" enctype="multipart/form-data">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
<div class="form-group" @style('display:none;')>
|
||||||
|
<label for="edit-id_penyakit">ID Penyakit</label>
|
||||||
|
<input type="text" name="id_penyakit" class="form-control" id="id_penyakit" placeholder="Enter name">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="edit-kode_penyakit">Kode Penyakit</label>
|
||||||
|
<input type="text" name="kode_penyakit" class="form-control" id="kode_penyakit" placeholder="Enter name">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="edit-kode_gejala">Nama Penyakit</label>
|
||||||
|
<input type="text" name="nama_penyakit" class="form-control" id="nama_penyakit" placeholder="Enter Penyakit">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="edit-deskripsi_penyakit">Deskripsi Penyakit</label>
|
||||||
|
<input type="text" name="deskripsi_penyakit" class="form-control" id="deskripsi_penyakit" placeholder="Enter Deskripsi Penyakit">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="edit-solusi">Solusi</label>
|
||||||
|
<input type="text" name="solusi" class="form-control" id="solusi" placeholder="Enter Solusi">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Tombol Submit untuk mengirimkan formulir -->
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -113,11 +113,11 @@ class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100
|
||||||
<td>{{ $data->solusi }}</td>
|
<td>{{ $data->solusi }}</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
{{-- <a href="#" class="edit-button" data-bs-toggle="modal" data-bs-target="#edit-gejala"
|
<a href="#" class="edit-button" data-bs-toggle="modal" data-bs-target="#edit-penyakit"
|
||||||
data-id_gejala="{{ $data->id_gejala }}" data-kode-gejala="{{ $data->kode_gejala }}"
|
data-id_penyakit="{{ $data->id_penyakit }}" data-kode_penyakit="{{ $data->kode_penyakit }}"
|
||||||
data-gejala="{{ $data->gejala }}" data-nilai-densitas="{{ $data->nilai_densitas}}">
|
data-nama_penyakit="{{ $data->nama_penyakit }}" data-deskripsi_penyakit="{{ $data->deskripsi_penyakit}}", data-solusi="{{ $data->solusi}}">
|
||||||
<i class="fas fa-edit"></i>
|
<i class="fas fa-edit"></i>
|
||||||
</a> --}}
|
</a>
|
||||||
<a href="{{ route('delete-penyakit', $data->id_penyakit) }}" onclick="return confirm('Apakah Anda yakin ingin menghapus data penyakit ini?')">
|
<a href="{{ route('delete-penyakit', $data->id_penyakit) }}" onclick="return confirm('Apakah Anda yakin ingin menghapus data penyakit ini?')">
|
||||||
<i class="fas fa-trash-alt" style="color: red"></i>
|
<i class="fas fa-trash-alt" style="color: red"></i>
|
||||||
</a>
|
</a>
|
||||||
|
@ -126,7 +126,7 @@ class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
{{-- @include('dashboard.produk.edit-produk') --}}
|
@include('dashboard.penyakit.edit-penyakit')
|
||||||
|
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -24,12 +24,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Route::get('/gejala', function () {
|
|
||||||
return view('gejala');
|
|
||||||
});
|
|
||||||
|
|
||||||
Route::get('/gejala', [GejalaController::class, 'index']);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,14 +36,21 @@
|
||||||
|
|
||||||
Auth::routes();
|
Auth::routes();
|
||||||
Route::middleware(['auth'])->group(function () {
|
Route::middleware(['auth'])->group(function () {
|
||||||
|
|
||||||
//Aturan
|
//Aturan
|
||||||
Route::get('/aturan', [AturanController::class, 'index']);
|
Route::get('aturan', [AturanController::class, 'index'])->name('aturan');
|
||||||
Route::post('/add-aturan', [AturanController::class, 'store'])->name('add-aturan');
|
Route::post('add-aturan', [AturanController::class, 'store'])->name('add-aturan');
|
||||||
Route::get('/delete-aturan/{id_aturan}',[AturanController::class,'destroy'])->name('delete-aturan');
|
Route::get('delete-aturan/{id_aturan}',[AturanController::class,'destroy'])->name('delete-aturan');
|
||||||
|
Route::put('update-aturan/{id_aturan}',[AturanController::class,'update'])->name('update-aturan');
|
||||||
|
|
||||||
//Gejala
|
//Gejala
|
||||||
Route::post('/add-gejala', [GejalaController::class, 'store'])->name("add-gejala");
|
Route::get('gejala',[GejalaController::class,'index'])->name('gejala');
|
||||||
|
Route::post('add-gejala', [GejalaController::class, 'store'])->name("add-gejala");
|
||||||
Route::get('delete-produk/{id_gejala}', [App\Http\Controllers\GejalaController::class,'destroy'])->name('delete-gejala');
|
Route::get('delete-produk/{id_gejala}', [App\Http\Controllers\GejalaController::class,'destroy'])->name('delete-gejala');
|
||||||
|
Route::put('update-gejala/{id_gejala}',[GejalaController::class,'update'])->name('update-gejala');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//konsultasi
|
//konsultasi
|
||||||
Route::get('diagnosa', [KonsultasiController::class, 'index']);
|
Route::get('diagnosa', [KonsultasiController::class, 'index']);
|
||||||
|
@ -58,12 +59,13 @@
|
||||||
Route::get('cetakHasil/{id_hasil}', [KonsultasiController::class, 'cetakHasil']);
|
Route::get('cetakHasil/{id_hasil}', [KonsultasiController::class, 'cetakHasil']);
|
||||||
Route::get('logoutt', [LoginController::class, 'logout']);
|
Route::get('logoutt', [LoginController::class, 'logout']);
|
||||||
|
|
||||||
//Penyakit
|
|
||||||
Route::get('/penyakit', [PenyakitController::class, 'index']);
|
|
||||||
Route::post('/add-penyakit', [PenyakitController::class, 'store'])->name("add-gejala");
|
|
||||||
Route::get('delete-penyakit/{id_penyakit}', [App\Http\Controllers\PenyakitController::class,'destroy'])->name('delete-penyakit');
|
|
||||||
|
|
||||||
|
//Penyakit
|
||||||
|
Route::get('penyakit', [PenyakitController::class, 'index'])->name('penyakit');
|
||||||
|
Route::post('add-penyakit', [PenyakitController::class, 'store'])->name("add-penyakit");
|
||||||
|
Route::get('delete-penyakit/{id_penyakit}', [App\Http\Controllers\PenyakitController::class,'destroy'])->name('delete-penyakit');
|
||||||
|
Route::put('update-penyakit/{id_penyakit}',[PenyakitController::class,'update'])->name('update-penyakit');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
|
// Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
|
||||||
|
|
Loading…
Reference in New Issue