daftar siswa update (undone)
This commit is contained in:
parent
b6d0f7de72
commit
949e483f7e
|
|
@ -0,0 +1,116 @@
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Siswa;
|
||||||
|
use App\Models\Kelas;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
||||||
|
class SiswaController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$query = Siswa::with('kelas'); // Eager load relasi kelas
|
||||||
|
|
||||||
|
// SEARCH
|
||||||
|
if ($request->has('search')) {
|
||||||
|
$search = $request->search;
|
||||||
|
$query->where('nama', 'like', "%$search%")
|
||||||
|
->orWhere('nisn', 'like', "%$search%");
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILTER BY KELAS
|
||||||
|
if ($request->has('filter_kelas') && $request->filter_kelas != '') {
|
||||||
|
$query->where('id_kelas', $request->filter_kelas);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SHOW PER PAGE
|
||||||
|
$perPage = $request->get('perPage', 10);
|
||||||
|
|
||||||
|
$siswas = $query->paginate($perPage)->appends($request->all());
|
||||||
|
|
||||||
|
// Ambil semua kelas untuk dropdown filter
|
||||||
|
$kelass = Kelas::orderBy('tingkat')->orderBy('nama_kelas')->get();
|
||||||
|
|
||||||
|
return view('admin.siswa.index', compact('siswas', 'kelass'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'nisn' => 'required|string|max:20|unique:siswas,nisn',
|
||||||
|
'nama' => 'required|string|max:100',
|
||||||
|
'tempat_lahir' => 'required|string|max:50',
|
||||||
|
'tanggal_lahir' => 'required|date',
|
||||||
|
'id_kelas' => 'required|exists:kelas,id_kelas',
|
||||||
|
'password' => 'required|string|min:6',
|
||||||
|
], [
|
||||||
|
'nisn.required' => 'NISN wajib diisi',
|
||||||
|
'nisn.unique' => 'NISN sudah terdaftar',
|
||||||
|
'nama.required' => 'Nama wajib diisi',
|
||||||
|
'tempat_lahir.required' => 'Tempat lahir wajib diisi',
|
||||||
|
'tanggal_lahir.required' => 'Tanggal lahir wajib diisi',
|
||||||
|
'id_kelas.required' => 'Kelas wajib dipilih',
|
||||||
|
'id_kelas.exists' => 'Kelas tidak valid',
|
||||||
|
'password.required' => 'Password wajib diisi',
|
||||||
|
'password.min' => 'Password minimal 6 karakter',
|
||||||
|
]);
|
||||||
|
|
||||||
|
Siswa::create([
|
||||||
|
'nisn' => $validated['nisn'],
|
||||||
|
'nama' => $validated['nama'],
|
||||||
|
'tempat_lahir' => $validated['tempat_lahir'],
|
||||||
|
'tanggal_lahir' => $validated['tanggal_lahir'],
|
||||||
|
'id_kelas' => $validated['id_kelas'],
|
||||||
|
'password' => Hash::make($validated['password']),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->route('admin.siswa.index')
|
||||||
|
->with('success', 'Data siswa berhasil ditambahkan!');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $nisn)
|
||||||
|
{
|
||||||
|
$siswa = Siswa::findOrFail($nisn);
|
||||||
|
|
||||||
|
$validated = $request->validate([
|
||||||
|
'nama' => 'required|string|max:100',
|
||||||
|
'tempat_lahir' => 'required|string|max:50',
|
||||||
|
'tanggal_lahir' => 'required|date',
|
||||||
|
'id_kelas' => 'required|exists:kelas,id_kelas',
|
||||||
|
'password' => 'nullable|string|min:6',
|
||||||
|
], [
|
||||||
|
'nama.required' => 'Nama wajib diisi',
|
||||||
|
'tempat_lahir.required' => 'Tempat lahir wajib diisi',
|
||||||
|
'tanggal_lahir.required' => 'Tanggal lahir wajib diisi',
|
||||||
|
'id_kelas.required' => 'Kelas wajib dipilih',
|
||||||
|
'id_kelas.exists' => 'Kelas tidak valid',
|
||||||
|
'password.min' => 'Password minimal 6 karakter',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$siswa->nama = $validated['nama'];
|
||||||
|
$siswa->tempat_lahir = $validated['tempat_lahir'];
|
||||||
|
$siswa->tanggal_lahir = $validated['tanggal_lahir'];
|
||||||
|
$siswa->id_kelas = $validated['id_kelas'];
|
||||||
|
|
||||||
|
// Update password hanya jika diisi
|
||||||
|
if ($request->filled('password')) {
|
||||||
|
$siswa->password = Hash::make($validated['password']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$siswa->save();
|
||||||
|
|
||||||
|
return redirect()->route('admin.siswa.index')
|
||||||
|
->with('success', 'Data siswa berhasil diupdate!');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($nisn)
|
||||||
|
{
|
||||||
|
$siswa = Siswa::findOrFail($nisn);
|
||||||
|
$siswa->delete();
|
||||||
|
|
||||||
|
return redirect()->route('admin.siswa.index')
|
||||||
|
->with('success', 'Data siswa berhasil dihapus!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,28 +9,30 @@ class Siswa extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
protected $table = 'siswas';
|
protected $table = 'siswas';
|
||||||
|
|
||||||
protected $primaryKey = 'nisn';
|
protected $primaryKey = 'nisn';
|
||||||
|
|
||||||
public $incrementing = false;
|
public $incrementing = false;
|
||||||
|
|
||||||
protected $keyType = 'string';
|
protected $keyType = 'string';
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'nisn',
|
'nisn',
|
||||||
'password',
|
|
||||||
'nama',
|
'nama',
|
||||||
'tempat_lahir',
|
'tempat_lahir',
|
||||||
'tanggal_lahir',
|
'tanggal_lahir',
|
||||||
'id_kelas',
|
'id_kelas',
|
||||||
|
'password',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
'password',
|
'password',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Relasi ke Kelas
|
||||||
public function kelas()
|
public function kelas()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Kelas::class, 'id_kelas', 'id_kelas');
|
return $this->belongsTo(Kelas::class, 'id_kelas', 'id_kelas');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,428 @@
|
||||||
|
|
||||||
|
@extends('admin.layouts.app')
|
||||||
|
|
||||||
|
@section('title', 'Daftar Siswa')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.page-title {
|
||||||
|
font-size: 30px;
|
||||||
|
font-weight: 800;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
margin-top: -20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-card {
|
||||||
|
background: white;
|
||||||
|
border-radius: 20px;
|
||||||
|
border: 2px solid #e5e5e5;
|
||||||
|
padding: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary-custom {
|
||||||
|
background: #2b8ef3;
|
||||||
|
color: white;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 8px 18px;
|
||||||
|
border: none;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-header {
|
||||||
|
background: #a5e6ba;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box {
|
||||||
|
background: #a5e6ba;
|
||||||
|
border-radius: 30px;
|
||||||
|
padding: 6px 15px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box input {
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
background: transparent;
|
||||||
|
width: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-icon {
|
||||||
|
width: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
margin: 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.per-page-select, .filter-select {
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 5px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal {
|
||||||
|
left: auto !important;
|
||||||
|
right: 0;
|
||||||
|
width: calc(100% - 250px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-backdrop {
|
||||||
|
left: auto !important;
|
||||||
|
right: 0;
|
||||||
|
width: calc(100% - 250px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-dialog {
|
||||||
|
margin-right: auto;
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-content {
|
||||||
|
border-radius: 20px;
|
||||||
|
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-header-pastel {
|
||||||
|
background: #FFD97D !important;
|
||||||
|
color: black !important;
|
||||||
|
border-bottom: none;
|
||||||
|
padding: 15px 20px;
|
||||||
|
border-top-left-radius: 20px;
|
||||||
|
border-top-right-radius: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-save-pastel {
|
||||||
|
background: #2b8ef3;
|
||||||
|
color: white;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 8px 18px;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<h3 class="page-title">DAFTAR SISWA</h3>
|
||||||
|
|
||||||
|
<div class="custom-card">
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||||
|
|
||||||
|
<button class="btn-primary-custom" data-bs-toggle="modal" data-bs-target="#modalTambah">
|
||||||
|
<img src="{{ asset('images/icon/main/add.png') }}" width="18">
|
||||||
|
Tambah Data
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<form method="GET">
|
||||||
|
<div class="search-box">
|
||||||
|
<input type="text" name="search" placeholder="Cari" value="{{ request('search') }}">
|
||||||
|
<button style="border:none;background:none">
|
||||||
|
<img src="{{ asset('images/icon/main/search.png') }}" width="18">
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form method="GET" class="mb-2">
|
||||||
|
<span>Tampilkan</span>
|
||||||
|
|
||||||
|
<select name="perPage" onchange="this.form.submit()" class="per-page-select">
|
||||||
|
<option value="10" {{ request('perPage') == 10 ? 'selected' : '' }}>10</option>
|
||||||
|
<option value="25" {{ request('perPage') == 25 ? 'selected' : '' }}>25</option>
|
||||||
|
<option value="50" {{ request('perPage') == 50 ? 'selected' : '' }}>50</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<span>data</span>
|
||||||
|
|
||||||
|
<span class="ms-3">Filter Kelas</span>
|
||||||
|
|
||||||
|
<select name="filter_kelas" onchange="this.form.submit()" class="filter-select">
|
||||||
|
<option value="">Semua Kelas</option>
|
||||||
|
@foreach($kelass as $kelas)
|
||||||
|
<option value="{{ $kelas->id_kelas }}"
|
||||||
|
{{ request('filter_kelas') == $kelas->id_kelas ? 'selected' : '' }}>
|
||||||
|
{{ $kelas->tingkat }} - {{ $kelas->nama_kelas }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<input type="hidden" name="search" value="{{ request('search') }}">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{{-- Alert Success --}}
|
||||||
|
@if(session('success'))
|
||||||
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||||
|
{{ session('success') }}
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<table class="table text-center align-middle">
|
||||||
|
<thead class="table-header">
|
||||||
|
<tr>
|
||||||
|
<th>No</th>
|
||||||
|
<th>NISN</th>
|
||||||
|
<th>Nama</th>
|
||||||
|
<th>Tempat Lahir</th>
|
||||||
|
<th>Tanggal Lahir</th>
|
||||||
|
<th>Kelas</th>
|
||||||
|
<th>Aksi</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
@forelse($siswas as $index => $siswa)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $siswas->firstItem() + $index }}</td>
|
||||||
|
<td>{{ $siswa->nisn }}</td>
|
||||||
|
<td>{{ $siswa->nama }}</td>
|
||||||
|
<td>{{ $siswa->tempat_lahir }}</td>
|
||||||
|
<td>{{ \Carbon\Carbon::parse($siswa->tanggal_lahir)->format('d M Y') }}</td>
|
||||||
|
<td>{{ $siswa->kelas->tingkat }} - {{ $siswa->kelas->nama_kelas }}</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<button onclick="openEditModal(
|
||||||
|
'{{ $siswa->nisn }}',
|
||||||
|
'{{ $siswa->nama }}',
|
||||||
|
'{{ $siswa->tempat_lahir }}',
|
||||||
|
'{{ $siswa->tanggal_lahir }}',
|
||||||
|
'{{ $siswa->id_kelas }}'
|
||||||
|
)" style="border:none;background:none">
|
||||||
|
<img src="{{ asset('images/icon/main/edit.png') }}" class="action-icon">
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<form action="{{ route('admin.siswa.destroy', $siswa->nisn) }}"
|
||||||
|
method="POST" class="d-inline"
|
||||||
|
onsubmit="return confirm('Yakin ingin menghapus data siswa {{ $siswa->nama }}?')">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<button type="submit" style="border:none;background:none">
|
||||||
|
<img src="{{ asset('images/icon/main/del.png') }}" class="action-icon">
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="7">Belum ada data siswa</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-end">
|
||||||
|
{{ $siswas->links() }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- MODAL TAMBAH --}}
|
||||||
|
<div class="modal fade" id="modalTambah">
|
||||||
|
<div class="modal-dialog modal-lg modal-dialog-centered">
|
||||||
|
<div class="modal-content">
|
||||||
|
|
||||||
|
<div class="modal-header modal-header-pastel">
|
||||||
|
<h5 class="modal-title w-100">Tambah Data Siswa</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form action="{{ route('admin.siswa.store') }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<div class="modal-body">
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label>NISN <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" name="nisn" class="form-control @error('nisn') is-invalid @enderror"
|
||||||
|
value="{{ old('nisn') }}" required>
|
||||||
|
@error('nisn')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label>Nama Lengkap <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" name="nama" class="form-control @error('nama') is-invalid @enderror"
|
||||||
|
value="{{ old('nama') }}" required>
|
||||||
|
@error('nama')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label>Tempat Lahir <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" name="tempat_lahir" class="form-control @error('tempat_lahir') is-invalid @enderror"
|
||||||
|
value="{{ old('tempat_lahir') }}" required>
|
||||||
|
@error('tempat_lahir')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label>Tanggal Lahir <span class="text-danger">*</span></label>
|
||||||
|
<input type="date" name="tanggal_lahir" class="form-control @error('tanggal_lahir') is-invalid @enderror"
|
||||||
|
value="{{ old('tanggal_lahir') }}" required>
|
||||||
|
@error('tanggal_lahir')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label>Kelas <span class="text-danger">*</span></label>
|
||||||
|
<select name="id_kelas" class="form-control @error('id_kelas') is-invalid @enderror" required>
|
||||||
|
<option value="">Pilih Kelas</option>
|
||||||
|
@foreach($kelass as $kelas)
|
||||||
|
<option value="{{ $kelas->id_kelas }}" {{ old('id_kelas') == $kelas->id_kelas ? 'selected' : '' }}>
|
||||||
|
{{ $kelas->tingkat }} - {{ $kelas->nama_kelas }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('id_kelas')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label>Password <span class="text-danger">*</span></label>
|
||||||
|
<input type="password" name="password" class="form-control @error('password') is-invalid @enderror" required>
|
||||||
|
@error('password')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
|
<small class="text-muted">Minimal 6 karakter</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
|
||||||
|
<button class="btn btn-success">Simpan Data</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- MODAL EDIT --}}
|
||||||
|
<div class="modal fade" id="modalEdit">
|
||||||
|
<div class="modal-dialog modal-lg modal-dialog-centered">
|
||||||
|
<div class="modal-content">
|
||||||
|
|
||||||
|
<div class="modal-header modal-header-pastel">
|
||||||
|
<h5 class="modal-title w-100">Edit Data Siswa</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form id="formEdit" method="POST">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
|
||||||
|
<div class="modal-body">
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label>NISN</label>
|
||||||
|
<input type="text" id="editNisn" class="form-control bg-light" disabled>
|
||||||
|
<small class="text-muted">NISN tidak dapat diubah</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label>Nama Lengkap <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" id="editNama" name="nama" class="form-control" required>
|
||||||
|
@error('nama')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label>Tempat Lahir <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" id="editTempatLahir" name="tempat_lahir" class="form-control" required>
|
||||||
|
@error('tempat_lahir')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label>Tanggal Lahir <span class="text-danger">*</span></label>
|
||||||
|
<input type="date" id="editTanggalLahir" name="tanggal_lahir" class="form-control" required>
|
||||||
|
@error('tanggal_lahir')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label>Kelas <span class="text-danger">*</span></label>
|
||||||
|
<select id="editKelas" name="id_kelas" class="form-control" required>
|
||||||
|
<option value="">Pilih Kelas</option>
|
||||||
|
@foreach($kelass as $kelas)
|
||||||
|
<option value="{{ $kelas->id_kelas }}">
|
||||||
|
{{ $kelas->tingkat }} - {{ $kelas->nama_kelas }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('id_kelas')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label>Password Baru</label>
|
||||||
|
<input type="password" name="password" class="form-control" placeholder="Kosongkan jika tidak ingin mengubah">
|
||||||
|
@error('password')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
|
<small class="text-muted">Isi hanya jika ingin mengubah password</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
|
||||||
|
<button class="btn btn-success">Update</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function openEditModal(nisn, nama, tempatLahir, tanggalLahir, idKelas) {
|
||||||
|
document.getElementById('editNisn').value = nisn;
|
||||||
|
document.getElementById('editNama').value = nama;
|
||||||
|
document.getElementById('editTempatLahir').value = tempatLahir;
|
||||||
|
document.getElementById('editTanggalLahir').value = tanggalLahir;
|
||||||
|
document.getElementById('editKelas').value = idKelas;
|
||||||
|
|
||||||
|
document.getElementById('formEdit').action = "{{ url('admin/siswa') }}/" + nisn;
|
||||||
|
|
||||||
|
new bootstrap.Modal(document.getElementById('modalEdit')).show();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
@if ($errors->any())
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
|
|
||||||
|
@if(session('error_from') == 'edit')
|
||||||
|
var modal = new bootstrap.Modal(document.getElementById('modalEdit'));
|
||||||
|
@else
|
||||||
|
var modal = new bootstrap.Modal(document.getElementById('modalTambah'));
|
||||||
|
@endif
|
||||||
|
|
||||||
|
modal.show();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@endsection
|
||||||
|
|
@ -8,9 +8,10 @@
|
||||||
use App\Http\Controllers\Admin\AdminController;
|
use App\Http\Controllers\Admin\AdminController;
|
||||||
use App\Http\Controllers\Admin\GuruController;
|
use App\Http\Controllers\Admin\GuruController;
|
||||||
use App\Http\Controllers\Admin\KelasController;
|
use App\Http\Controllers\Admin\KelasController;
|
||||||
|
use App\Http\Controllers\Admin\SiswaController;
|
||||||
|
|
||||||
// use App\Http\Controllers\GuruController;
|
// use App\Http\Controllers\GuruController;
|
||||||
use App\Http\Controllers\SiswaController;
|
// use App\Http\Controllers\SiswaController;
|
||||||
// use App\Http\Controllers\KelasController;
|
// use App\Http\Controllers\KelasController;
|
||||||
use App\Http\Controllers\MapelController;
|
use App\Http\Controllers\MapelController;
|
||||||
use App\Http\Controllers\ChallengeController;
|
use App\Http\Controllers\ChallengeController;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue