update
This commit is contained in:
parent
3449d4f954
commit
783d5361ae
|
@ -15,16 +15,13 @@ public function index()
|
|||
return view('layouts.diagnosa.detailpenyakit', compact('penyakit'));
|
||||
}
|
||||
|
||||
// PenyakitController.php
|
||||
public function show($id)
|
||||
{
|
||||
$penyakit = Penyakit::findOrFail($id); // Ambil data penyakit berdasarkan ID
|
||||
// Ambil data penyakit berdasarkan ID dan muat relasi gejalas
|
||||
$penyakit = Penyakit::with('gejala')->findOrFail($id);
|
||||
|
||||
// Ambil ID gejala yang terkait dengan penyakit ini
|
||||
$gejala_ids = explode(',', $penyakit->gejala);
|
||||
|
||||
// Ambil nama gejala berdasarkan ID
|
||||
$gejala_list = Gejala::whereIn('id', $gejala_ids)->pluck('nama_gejala');
|
||||
|
||||
return view('layouts.diagnosa.rinciandetailpenyakit', compact('penyakit', 'gejala_list'));
|
||||
// Mengirim data penyakit ke view
|
||||
return view('layouts.diagnosa.rinciandetailpenyakit', compact('penyakit'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
|
@ -14,6 +16,16 @@ public function index()
|
|||
// Return the profile view with the authenticated user details
|
||||
return view('layouts.profile', ['account' => $account]);
|
||||
}
|
||||
}
|
||||
public function updatePassword(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'passupdate' => 'required|string|min:8',
|
||||
]);
|
||||
|
||||
?>
|
||||
$user = auth()->user();
|
||||
$user->password = Hash::make($request->passupdate);
|
||||
$user->save();
|
||||
|
||||
return back()->with('success', 'Password berhasil diperbarui.');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,6 @@ public function store(Request $request)
|
|||
'deskripsi' => 'required|string',
|
||||
'penanganan' => 'required|string',
|
||||
'gambar' => 'required|image|mimes:jpeg,png,jpg,gif',
|
||||
'gejala' => 'required|array', // Memastikan gejala yang dipilih adalah array
|
||||
'gejala.*' => 'exists:gejala,id', // Memastikan ID gejala ada di tabel gejala
|
||||
]);
|
||||
|
||||
// Upload gambar
|
||||
|
@ -38,8 +36,6 @@ public function store(Request $request)
|
|||
$namaGambar = time() . '_' . $gambar->getClientOriginalName();
|
||||
$gambar->move(public_path('assets/images'), $namaGambar);
|
||||
|
||||
// Mengambil ID gejala yang dipilih dan mengubahnya menjadi string
|
||||
$gejalaIds = implode(',', $request->gejala);
|
||||
|
||||
// Simpan data penyakit ke database
|
||||
Penyakit::create([
|
||||
|
@ -49,7 +45,6 @@ public function store(Request $request)
|
|||
'deskripsi' => $request->deskripsi,
|
||||
'penanganan' => $request->penanganan,
|
||||
'gambar' => $namaGambar,
|
||||
'gejala' => $gejalaIds, // Simpan ID gejala dalam bentuk string
|
||||
]);
|
||||
|
||||
return redirect()->back()->with('success', 'Data penyakit berhasil ditambahkan!');
|
||||
|
@ -58,10 +53,10 @@ public function store(Request $request)
|
|||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
// HAPUS ini: dd($request->all()); // <-- Hapus baris ini
|
||||
|
||||
// Ambil data penyakit berdasarkan ID
|
||||
$penyakit = Penyakit::findOrFail($id);
|
||||
|
||||
|
||||
// Validasi data yang diterima dari request tanpa gejala
|
||||
$request->validate([
|
||||
'kode_penyakit' => 'required|string|max:10|unique:penyakit,kode_penyakit,' . $penyakit->id,
|
||||
'nama_penyakit' => 'required|string|max:100',
|
||||
|
@ -69,13 +64,8 @@ public function update(Request $request, $id)
|
|||
'deskripsi' => 'required|string',
|
||||
'penanganan' => 'required|string',
|
||||
'gambar' => 'nullable|image|mimes:jpeg,png,jpg,gif',
|
||||
'gejala' => 'required|array', // Validasi gejala yang dipilih
|
||||
'gejala.*' => 'exists:gejala,id',
|
||||
]);
|
||||
|
||||
// Menyimpan log dengan memeriksa apakah gejala ada
|
||||
Log::info('Gejala yang diterima: ', ['gejala' => $request->gejala]); // Menyimpan data dalam array
|
||||
|
||||
// Update data penyakit
|
||||
$penyakit->kode_penyakit = $request->kode_penyakit;
|
||||
$penyakit->nama_penyakit = $request->nama_penyakit;
|
||||
|
@ -97,15 +87,6 @@ public function update(Request $request, $id)
|
|||
|
||||
$penyakit->gambar = $namaGambar;
|
||||
}
|
||||
|
||||
// Menyinkronkan gejala yang dipilih
|
||||
if ($request->has('gejala')) {
|
||||
$penyakit->gejala = implode(',', $request->gejala); // Simpan ID yang dipilih dalam format string
|
||||
Log::info('Gejala yang dipilih disimpan: ', ['gejala' => $penyakit->gejala]); // Menampilkan gejala yang disimpan
|
||||
} else {
|
||||
$penyakit->gejala = ''; // Jika tidak ada gejala yang dipilih
|
||||
}
|
||||
|
||||
// Simpan perubahan penyakit
|
||||
$penyakit->save();
|
||||
|
||||
|
@ -113,6 +94,7 @@ public function update(Request $request, $id)
|
|||
}
|
||||
|
||||
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$penyakit = Penyakit::findOrFail($id);
|
||||
|
@ -128,4 +110,4 @@ public function destroy($id)
|
|||
|
||||
return redirect()->back()->with('success', 'Data penyakit berhasil dihapus beserta gambarnya.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,15 @@
|
|||
</div>
|
||||
@endif
|
||||
|
||||
<style>
|
||||
ul {
|
||||
list-style-type: none;
|
||||
/* Menghapus bullet points */
|
||||
padding-left: 0;
|
||||
/* Menghilangkan indentasi default */
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- DataTable -->
|
||||
<div class="card mb-4" id="history" data-wow-duration="1s" data-wow-delay="0.5s">
|
||||
<div class="card-body">
|
||||
|
@ -36,7 +45,6 @@
|
|||
<th>Nama Penyakit</th>
|
||||
<th>Sub Judul</th>
|
||||
<th>Deskripsi</th>
|
||||
<th>Gejala</th>
|
||||
<th>Penanganan</th>
|
||||
<th>Gambar</th>
|
||||
<th>Aksi</th>
|
||||
|
@ -48,7 +56,6 @@
|
|||
<th>Nama Penyakit</th>
|
||||
<th>Sub Judul</th>
|
||||
<th>Deskripsi</th>
|
||||
<th>Gejala</th>
|
||||
<th>Penanganan</th>
|
||||
<th>Gambar</th>
|
||||
<th>Aksi</th>
|
||||
|
@ -62,22 +69,15 @@
|
|||
<td>{{ $penyakit->nama_penyakit }}</td>
|
||||
<td>{{ $penyakit->subjudul }}</td>
|
||||
<td>{{ $penyakit->deskripsi }}</td>
|
||||
|
||||
<td>
|
||||
@php
|
||||
$id_gejala = explode(',', $penyakit->gejala);
|
||||
$nama_gejala = collect($id_gejala)->map(function ($id) use ($gejala) {
|
||||
$gejala = $gejala->firstWhere('id', (int)$id);
|
||||
return $gejala ? $gejala->nama_gejala : null;
|
||||
})->filter();
|
||||
@endphp
|
||||
<ul>
|
||||
@foreach ($nama_gejala as $nama)
|
||||
<li>{{ $nama }}</li>
|
||||
@foreach(explode("\n", $penyakit->penanganan) as $item)
|
||||
<li>{{ $item }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</td>
|
||||
|
||||
<td>{{ $penyakit->penanganan }}</td>
|
||||
<td>
|
||||
<img src="{{ asset('assets/images/' . $penyakit->gambar) }}" width="100" alt="Gambar Penyakit">
|
||||
</td>
|
||||
|
@ -132,36 +132,6 @@
|
|||
<input type="file" class="form-control" name="gambar" accept="image/*">
|
||||
<small class="form-text text-muted">Gambar saat ini: <br><img src="{{ asset('assets/images/' . $penyakit->gambar) }}" width="100"></small>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Gejala</label>
|
||||
<div class="gejala-select-container">
|
||||
@php
|
||||
$selected_gejala = explode(',', $penyakit->gejala); // Ambil gejala yang sudah ada
|
||||
@endphp
|
||||
|
||||
<div class="mb-2">
|
||||
<button type="button" class="btn btn-sm btn-info pilih-semua-gejala" data-penyakit-id="{{ $penyakit->id }}">Pilih Semua</button>
|
||||
<button type="button" class="btn btn-sm btn-warning hapus-semua-gejala" data-penyakit-id="{{ $penyakit->id }}">Hapus Semua</button>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
@foreach($gejala as $item)
|
||||
<div class="col-md-6 mb-2">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input gejala-checkbox" type="checkbox"
|
||||
name="gejala[]" value="{{ $item->id }}"
|
||||
id="gejala{{ $penyakit->id }}_{{ $item->id }}"
|
||||
data-penyakit-id="{{ $penyakit->id }}"
|
||||
{{ in_array($item->id, $selected_gejala) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="gejala{{ $penyakit->id }}_{{ $item->id }}">
|
||||
{{ $item->nama_gejala }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tutup</button>
|
||||
|
@ -214,33 +184,6 @@
|
|||
<label for="gambar" class="form-label">Gambar</label>
|
||||
<input type="file" class="form-control" id="gambar" name="gambar" accept="image/*" required>
|
||||
</div>
|
||||
|
||||
<!-- Form Input Gejala sebagai Checkbox -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Gejala</label>
|
||||
<div class="gejala-select-container">
|
||||
<div class="mb-2">
|
||||
<button type="button" class="btn btn-sm btn-info pilih-semua-gejala" data-penyakit-id="tambah">Pilih Semua</button>
|
||||
<button type="button" class="btn btn-sm btn-warning hapus-semua-gejala" data-penyakit-id="tambah">Hapus Semua</button>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
@foreach($gejala as $item)
|
||||
<div class="col-md-6 mb-2">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input gejala-checkbox" type="checkbox"
|
||||
name="gejala[]" value="{{ $item->id }}"
|
||||
id="gejalaTambah_{{ $item->id }}"
|
||||
data-penyakit-id="tambah">
|
||||
<label class="form-check-label" for="gejalaTambah_{{ $item->id }}">
|
||||
{{ $item->nama_gejala }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tutup</button>
|
||||
|
@ -250,68 +193,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.custom-select-box {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
padding: 10px;
|
||||
border: 2px solid #ccc;
|
||||
border-radius: 10px;
|
||||
background-color: #fff;
|
||||
font-size: 14px;
|
||||
font-family: Arial, sans-serif;
|
||||
box-sizing: border-box;
|
||||
resize: none;
|
||||
transition: all 0.3s ease;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.custom-select-box:focus {
|
||||
border-color: #4caf50;
|
||||
outline: none;
|
||||
box-shadow: 0 0 5px rgba(76, 175, 80, 0.6);
|
||||
}
|
||||
|
||||
.custom-select-box option {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.custom-select-box option:checked {
|
||||
background-color: #4caf50;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.gejala-select-container {
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Handler untuk tombol "Pilih Semua"
|
||||
document.querySelectorAll('.pilih-semua-gejala').forEach(function(button) {
|
||||
button.addEventListener('click', function() {
|
||||
const penyakitId = this.getAttribute('data-penyakit-id');
|
||||
document.querySelectorAll(`.gejala-checkbox[data-penyakit-id="${penyakitId}"]`).forEach(function(checkbox) {
|
||||
checkbox.checked = true;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Handler untuk tombol "Hapus Semua"
|
||||
document.querySelectorAll('.hapus-semua-gejala').forEach(function(button) {
|
||||
button.addEventListener('click', function() {
|
||||
const penyakitId = this.getAttribute('data-penyakit-id');
|
||||
document.querySelectorAll(`.gejala-checkbox[data-penyakit-id="${penyakitId}"]`).forEach(function(checkbox) {
|
||||
checkbox.checked = false;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
|
@ -216,12 +216,25 @@
|
|||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Popup Profil -->
|
||||
@if(session('success'))
|
||||
<div id="flash-success" style="position: fixed; top: 10px; right: 10px; background: green; color: white; padding: 10px 20px; border-radius: 6px; z-index: 10001;">
|
||||
{{ session('success') }}
|
||||
</div>
|
||||
<script>
|
||||
setTimeout(() => {
|
||||
const flash = document.getElementById('flash-success');
|
||||
if (flash) flash.remove();
|
||||
}, 3000);
|
||||
</script>
|
||||
@endif
|
||||
<!-- Popup Profil -->
|
||||
<div id="popupOverlay"
|
||||
class="overlay-container">
|
||||
<div class="popup-box">
|
||||
<h2 style="color: #fe3f40;">PROFIL</h2>
|
||||
<form class="form-container">
|
||||
<form id="updatePasswordForm" class="form-container" method="POST" action="{{ route('user.updatePassword') }}">
|
||||
@csrf
|
||||
<label class="form-label"
|
||||
for="name">
|
||||
Username:
|
||||
|
@ -253,8 +266,7 @@ class="overlay-container">
|
|||
placeholder="Masukkan Password Baru"
|
||||
id="passupdate"
|
||||
name="passupdate" required>
|
||||
<button class="btn-submit"
|
||||
type="submit">
|
||||
<button class="btn-submit" id="submitBtn" type="submit" disabled>
|
||||
Submit
|
||||
</button>
|
||||
</form>
|
||||
|
@ -272,6 +284,16 @@ function togglePopup() {
|
|||
const overlay = document.getElementById('popupOverlay');
|
||||
overlay.classList.toggle('show');
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const passwordInput = document.getElementById("passupdate");
|
||||
const submitBtn = document.getElementById("submitBtn");
|
||||
|
||||
passwordInput.addEventListener("input", function() {
|
||||
const value = passwordInput.value;
|
||||
submitBtn.disabled = value.length < 8;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="content">
|
||||
|
|
|
@ -48,12 +48,13 @@
|
|||
<section class="section-container">
|
||||
<h2 class="section-title">Gejala</h2>
|
||||
<ol class="section-text" style="font-weight: 600; font-size: 15px;">
|
||||
@foreach($gejala_list as $gejala)
|
||||
<li>{{ $gejala }}</li>
|
||||
@foreach($penyakit->gejala as $gejala)
|
||||
<li>{{ $gejala->nama_gejala }}</li>
|
||||
@endforeach
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
|
||||
<section class="section-container">
|
||||
<h2 class="section-title">Penanganan</h2>
|
||||
<ol class="section-text" style="font-weight: 600; font-size: 15px;">
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
font-weight: 600 !important;
|
||||
}
|
||||
|
||||
.popup-box p{
|
||||
.popup-box p {
|
||||
font-size: 17px !important;
|
||||
font-weight: 400 !important;
|
||||
margin-bottom: 5px;
|
||||
|
@ -203,13 +203,24 @@
|
|||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@if(session('success'))
|
||||
<div id="flash-success" style="position: fixed; top: 10px; right: 10px; background: green; color: white; padding: 10px 20px; border-radius: 6px; z-index: 10001;">
|
||||
{{ session('success') }}
|
||||
</div>
|
||||
<script>
|
||||
setTimeout(() => {
|
||||
const flash = document.getElementById('flash-success');
|
||||
if (flash) flash.remove();
|
||||
}, 3000);
|
||||
</script>
|
||||
@endif
|
||||
<!-- Popup Profil -->
|
||||
<div id="popupOverlay"
|
||||
class="overlay-container">
|
||||
<div class="popup-box">
|
||||
<h2 style="color: #fe3f40;">PROFIL</h2>
|
||||
<form class="form-container">
|
||||
<form id="updatePasswordForm" class="form-container" method="POST" action="{{ route('user.updatePassword') }}">
|
||||
@csrf
|
||||
<label class="form-label"
|
||||
for="name">
|
||||
Username:
|
||||
|
@ -241,8 +252,7 @@ class="overlay-container">
|
|||
placeholder="Masukkan Password Baru"
|
||||
id="passupdate"
|
||||
name="passupdate" required>
|
||||
<button class="btn-submit"
|
||||
type="submit">
|
||||
<button class="btn-submit" id="submitBtn" type="submit" disabled>
|
||||
Submit
|
||||
</button>
|
||||
</form>
|
||||
|
@ -254,14 +264,25 @@ class="overlay-container">
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script>
|
||||
<!-- Scripts -->
|
||||
<script>
|
||||
function togglePopup() {
|
||||
const overlay = document.getElementById('popupOverlay');
|
||||
overlay.classList.toggle('show');
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const passwordInput = document.getElementById("passupdate");
|
||||
const submitBtn = document.getElementById("submitBtn");
|
||||
|
||||
passwordInput.addEventListener("input", function() {
|
||||
const value = passwordInput.value;
|
||||
submitBtn.disabled = value.length < 8;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<div class="content">
|
||||
@yield('content')
|
||||
</div>
|
||||
|
|
|
@ -83,6 +83,10 @@
|
|||
// Route untuk melakukan reset password
|
||||
Route::post('reset-password', [LupaPasswordController::class, 'resetPassword'])->name('reset.password');
|
||||
|
||||
// Update pass Profile
|
||||
Route::post('/profile/update-password', [ProfileController::class, 'updatePassword'])
|
||||
->name('user.updatePassword')
|
||||
->middleware('auth');
|
||||
|
||||
// Registration Routes
|
||||
Route::get('register', [RegisterController::class, 'showRegistrationForm'])->name('register');
|
||||
|
|
Loading…
Reference in New Issue