update tgl 5 maret
This commit is contained in:
parent
e19d32a1a4
commit
3c4f35a377
|
@ -24,4 +24,24 @@ public function show($id)
|
||||||
$karyawan = GajiModel::findOrFail($id);
|
$karyawan = GajiModel::findOrFail($id);
|
||||||
return response()->json($karyawan);
|
return response()->json($karyawan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$karyawan = GajiModel::findOrFail($id);
|
||||||
|
return view('GajiEdit', compact('karyawan'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$karyawan = GajiModel::findOrFail($id);
|
||||||
|
$karyawan->update($request->all());
|
||||||
|
return redirect()->route('gaji.index')->with('success', 'Data gaji berhasil diperbarui');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$karyawan = GajiModel::findOrFail($id);
|
||||||
|
$karyawan->delete();
|
||||||
|
return response()->json(['success' => true]);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -54,10 +54,14 @@ class="border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-bl
|
||||||
<td class="py-2 px-4 border-b">Rp {{ number_format($gaji->gaji, 0, ',', '.') }}</td>
|
<td class="py-2 px-4 border-b">Rp {{ number_format($gaji->gaji, 0, ',', '.') }}</td>
|
||||||
<td class="py-3 px-4 text-center">
|
<td class="py-3 px-4 text-center">
|
||||||
<div class="flex justify-center space-x-2">
|
<div class="flex justify-center space-x-2">
|
||||||
<button class="text-blue-600 hover:text-blue-800" title="Edit">
|
<a href="{{ route('gaji.edit', $gaji->id) }}"
|
||||||
|
class="text-blue-600 hover:text-blue-800"
|
||||||
|
title="Edit">
|
||||||
<i class="fas fa-edit"></i>
|
<i class="fas fa-edit"></i>
|
||||||
</button>
|
</a>
|
||||||
<button class="text-red-600 hover:text-red-800" title="Hapus">
|
<button onclick="deleteGaji({{ $gaji->id }})"
|
||||||
|
class="text-red-600 hover:text-red-800"
|
||||||
|
title="Hapus">
|
||||||
<i class="fas fa-trash"></i>
|
<i class="fas fa-trash"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -110,6 +114,28 @@ function filterTable() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteGaji(id) {
|
||||||
|
if (confirm('Apakah Anda yakin ingin menghapus data ini?')) {
|
||||||
|
fetch(`/gaji/${id}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-TOKEN': '{{ csrf_token() }}',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.success) {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
alert('Terjadi kesalahan saat menghapus data');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
@extends('Core.Sidebar')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="p-6 animate-fade-in">
|
||||||
|
<div class="mb-4 bg-blue-600 text-white p-4 rounded-lg shadow-md">
|
||||||
|
<h1 class="text-2xl font-bold">Edit Gaji Karyawan</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bg-white rounded-lg shadow-lg p-6">
|
||||||
|
<form action="{{ route('gaji.update', $karyawan->id) }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
|
||||||
|
<div class="mb-4">
|
||||||
|
<label class="block text-gray-700 text-sm font-bold mb-2">Nama Karyawan</label>
|
||||||
|
<input type="text" name="nama" value="{{ $karyawan->nama }}"
|
||||||
|
class="border rounded w-full py-2 px-3" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-4">
|
||||||
|
<label class="block text-gray-700 text-sm font-bold mb-2">Usia</label>
|
||||||
|
<input type="number" name="usia" value="{{ $karyawan->usia }}"
|
||||||
|
class="border rounded w-full py-2 px-3" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-4">
|
||||||
|
<label class="block text-gray-700 text-sm font-bold mb-2">Jabatan</label>
|
||||||
|
<input type="text" name="jabatan" value="{{ $karyawan->jabatan }}"
|
||||||
|
class="border rounded w-full py-2 px-3" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-4">
|
||||||
|
<label class="block text-gray-700 text-sm font-bold mb-2">Gaji</label>
|
||||||
|
<input type="number" name="gaji" value="{{ $karyawan->gaji }}"
|
||||||
|
class="border rounded w-full py-2 px-3" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex justify-end">
|
||||||
|
<button type="button" onclick="window.history.back()"
|
||||||
|
class="bg-gray-500 text-white px-4 py-2 rounded mr-2">
|
||||||
|
Batal
|
||||||
|
</button>
|
||||||
|
<button type="submit" class="bg-blue-500 text-white px-4 py-2 rounded">
|
||||||
|
Simpan Perubahan
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
|
@ -38,6 +38,9 @@
|
||||||
|
|
||||||
//untuk Uang Gaji
|
//untuk Uang Gaji
|
||||||
Route::get('/gaji', [GajiController::class, 'index'])->name('gaji.index');
|
Route::get('/gaji', [GajiController::class, 'index'])->name('gaji.index');
|
||||||
|
Route::delete('/gaji/{id}', [GajiController::class, 'destroy'])->name('gaji.destroy');
|
||||||
|
Route::get('/gaji/{id}/edit', [GajiController::class, 'edit'])->name('gaji.edit');
|
||||||
|
Route::put('/gaji/{id}', [GajiController::class, 'update'])->name('gaji.update');
|
||||||
|
|
||||||
// Tambahkan Data Karyawan
|
// Tambahkan Data Karyawan
|
||||||
Route::get('/data-karyawan', [DataKaryawanController::class, 'index'])->name('data-karyawan.index');
|
Route::get('/data-karyawan', [DataKaryawanController::class, 'index'])->name('data-karyawan.index');
|
||||||
|
|
Loading…
Reference in New Issue