Data Master (Belum Fix datanya jadi sementara itu dulu nanti setelah dianu datanya, diganti dengan yang asli)
to the moon kita berdansa
This commit is contained in:
parent
b91a5f76ea
commit
5168a6c249
|
|
@ -1,45 +1,68 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Guru;
|
||||
use App\Models\User;
|
||||
|
||||
class GuruController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return response()->json(Guru::with('user')->get());
|
||||
$guru = Guru::with('user')->get();
|
||||
return view('admin.guru.index', compact('guru'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$users = User::all(); // misalnya guru punya relasi ke user
|
||||
return view('admin.guru.create', compact('users'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'nama' => 'required|string|max:255',
|
||||
'bidang' => 'required|string|max:255',
|
||||
'alamat' => 'nullable|string',
|
||||
'no_hp' => 'nullable|string',
|
||||
]);
|
||||
|
||||
|
||||
Guru::create($request->all());
|
||||
return redirect()->route('guru.index')->with('success', 'Guru berhasil ditambahkan');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$guru = Guru::with('user')->findOrFail($id);
|
||||
return view('admin.guru.show', compact('guru'));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$guru = Guru::findOrFail($id);
|
||||
$users = User::all();
|
||||
return view('admin.guru.edit', compact('guru', 'users'));
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$request->validate([
|
||||
'user_id' => 'required|exists:users,id',
|
||||
'bidang' => 'required|string|max:255',
|
||||
]);
|
||||
|
||||
$guru = Guru::create($request->all());
|
||||
return response()->json($guru, 201);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$guru = Guru::with('user')->findOrFail($id);
|
||||
return response()->json($guru);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$guru = Guru::findOrFail($id);
|
||||
$guru->update($request->all());
|
||||
return response()->json($guru);
|
||||
|
||||
return redirect()->route('guru.index')->with('success', 'Data guru berhasil diperbarui');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
Guru::destroy($id);
|
||||
return response()->json(['message' => 'Guru deleted']);
|
||||
return redirect()->route('guru.index')->with('success', 'Guru berhasil dihapus');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,61 +3,81 @@
|
|||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Siswa;
|
||||
use App\Models\Kelas;
|
||||
use App\Models\WaliMurid;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class SiswaController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return response()->json(Siswa::with(['kelas', 'wali'])->get());
|
||||
$siswa = Siswa::with(['kelas','wali'])->paginate(10);
|
||||
return view('admin.siswa.index', compact('siswa'));
|
||||
}
|
||||
|
||||
public function store(SiswaRequest $request)
|
||||
public function create()
|
||||
{
|
||||
$siswa = Siswa::create($request->validated());
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Siswa berhasil ditambahkan',
|
||||
'data' => $siswa
|
||||
], 201);
|
||||
$kelas = Kelas::all();
|
||||
$wali = WaliMurid::all();
|
||||
return view('admin.siswa.create', compact('kelas','wali'));
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
public function store(Request $request)
|
||||
{
|
||||
$siswa = Siswa::with(['kelas', 'wali'])->findOrFail($id);
|
||||
|
||||
return response()->json($siswa);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$siswa = Siswa::findOrFail($id);
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'nama' => 'required|string|max:255',
|
||||
'nis' => 'required|string|max:50|unique:siswas,nis,' . $id . ',id',
|
||||
'tanggal_lahir' => 'required|date',
|
||||
'kelas_id' => 'required|exists:kelas,id',
|
||||
'wali_id' => 'required|exists:wali_murids,id', // <- pastikan nama tabel wali sesuai
|
||||
'foto' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$siswa->update($validatedData);
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Siswa berhasil diupdate',
|
||||
'data' => $siswa
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$siswa = Siswa::findOrFail($id);
|
||||
$siswa->delete();
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Siswa berhasil dihapus'
|
||||
$validated = $request->validate([
|
||||
'nama' => 'required|string|max:100',
|
||||
'nis' => 'required|string|max:50|unique:siswa,nis',
|
||||
'tanggal_lahir' => 'required|date',
|
||||
'kelas_id' => 'required|exists:kelas,id',
|
||||
'wali_id' => 'required|exists:wali_murid,id',
|
||||
'foto' => 'nullable|image|max:2048'
|
||||
]);
|
||||
|
||||
if ($request->hasFile('foto')) {
|
||||
$validated['foto'] = $request->file('foto')->store('siswa','public');
|
||||
}
|
||||
|
||||
Siswa::create($validated);
|
||||
return redirect()->route('siswa.index')->with('success','Siswa berhasil ditambahkan');
|
||||
}
|
||||
}
|
||||
|
||||
public function edit(Siswa $siswa)
|
||||
{
|
||||
$kelas = Kelas::all();
|
||||
$wali = WaliMurid::all();
|
||||
return view('admin.siswa.edit', compact('siswa','kelas','wali'));
|
||||
}
|
||||
|
||||
public function update(Request $request, Siswa $siswa)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'nama' => 'required|string|max:100',
|
||||
'nis' => 'required|string|max:50|unique:siswa,nis,'.$siswa->id,
|
||||
'tanggal_lahir' => 'required|date',
|
||||
'kelas_id' => 'required|exists:kelas,id',
|
||||
'wali_id' => 'required|exists:wali_murid,id',
|
||||
'foto' => 'nullable|image|max:2048'
|
||||
]);
|
||||
|
||||
if ($request->hasFile('foto')) {
|
||||
if ($siswa->foto && Storage::disk('public')->exists($siswa->foto)) {
|
||||
Storage::disk('public')->delete($siswa->foto);
|
||||
}
|
||||
$validated['foto'] = $request->file('foto')->store('siswa','public');
|
||||
}
|
||||
|
||||
$siswa->update($validated);
|
||||
return redirect()->route('siswa.index')->with('success','Siswa berhasil diupdate');
|
||||
}
|
||||
|
||||
public function destroy(Siswa $siswa)
|
||||
{
|
||||
if ($siswa->foto && Storage::disk('public')->exists($siswa->foto)) {
|
||||
Storage::disk('public')->delete($siswa->foto);
|
||||
}
|
||||
$siswa->delete();
|
||||
return redirect()->route('siswa.index')->with('success','Siswa berhasil dihapus');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,44 +3,64 @@
|
|||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\WaliMurid;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class WaliMuridController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return response()->json(WaliMurid::with('user')->get());
|
||||
// ambil semua wali murid + user terkait
|
||||
$wali = WaliMurid::with('user')->get();
|
||||
return view('admin.wali.index', compact('wali'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
// ambil data user untuk dropdown (jika sudah punya akun)
|
||||
$users = User::where('role', 'wali')->get();
|
||||
return view('admin.wali.create', compact('users'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'user_id' => 'required|exists:users,id',
|
||||
'alamat' => 'nullable|string',
|
||||
'pekerjaan' => 'nullable|string',
|
||||
'nama' => 'required|string|max:255',
|
||||
'alamat' => 'nullable|string',
|
||||
'lokasi_lat' => 'nullable|numeric',
|
||||
'lokasi_lng' => 'nullable|numeric',
|
||||
]);
|
||||
|
||||
$wali = WaliMurid::create($request->all());
|
||||
return response()->json($wali, 201);
|
||||
WaliMurid::create($request->all());
|
||||
|
||||
return redirect()->route('wali.index')->with('success', 'Wali Murid berhasil ditambahkan');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
public function edit(WaliMurid $wali)
|
||||
{
|
||||
$wali = WaliMurid::with('user')->findOrFail($id);
|
||||
return response()->json($wali);
|
||||
$users = User::where('role', 'wali')->get();
|
||||
return view('admin.wali.edit', compact('wali', 'users'));
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
public function update(Request $request, WaliMurid $wali)
|
||||
{
|
||||
$wali = WaliMurid::findOrFail($id);
|
||||
$request->validate([
|
||||
'nama' => 'required|string|max:255',
|
||||
'alamat' => 'nullable|string',
|
||||
'lokasi_lat' => 'nullable|numeric',
|
||||
'lokasi_lng' => 'nullable|numeric',
|
||||
]);
|
||||
|
||||
$wali->update($request->all());
|
||||
return response()->json($wali);
|
||||
|
||||
return redirect()->route('wali.index')->with('success', 'Wali Murid berhasil diperbarui');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
public function destroy(WaliMurid $wali)
|
||||
{
|
||||
WaliMurid::destroy($id);
|
||||
return response()->json(['message' => 'Wali Murid deleted']);
|
||||
$wali->delete();
|
||||
|
||||
return redirect()->route('wali.index')->with('success', 'Wali Murid berhasil dihapus');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,4 +32,11 @@ public function login(Request $request)
|
|||
// kalau email atau password salah
|
||||
return back()->with('error', 'Username atau password salah!');
|
||||
}
|
||||
public function logout(Request $request)
|
||||
{
|
||||
Auth::logout();
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
return redirect('/login');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="bg-white shadow-md rounded-lg p-6 max-w-xl mx-auto">
|
||||
<h1 class="text-xl font-semibold text-gray-700 mb-4">➕ Tambah Guru</h1>
|
||||
|
||||
<form action="{{ route('guru.store') }}" method="POST">
|
||||
@csrf
|
||||
<div class="mb-4">
|
||||
<label class="block text-gray-700 mb-1">Nama</label>
|
||||
<input type="text" name="nama"
|
||||
class="w-full border rounded px-3 py-2 focus:ring focus:ring-green-300" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-gray-700 mb-1">Bidang</label>
|
||||
<input type="text" name="bidang"
|
||||
class="w-full border rounded px-3 py-2 focus:ring focus:ring-green-300">
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-gray-700 mb-1">Telepon</label>
|
||||
<input type="text" name="telepon"
|
||||
class="w-full border rounded px-3 py-2 focus:ring focus:ring-green-300">
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-gray-700 mb-1">Alamat</label>
|
||||
<input type="text" name="alamat"
|
||||
class="w-full border rounded px-3 py-2 focus:ring focus:ring-green-300">
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex gap-3">
|
||||
<button type="submit"
|
||||
class="bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700 transition">
|
||||
Simpan
|
||||
</button>
|
||||
<a href="{{ route('guru.index') }}"
|
||||
class="bg-gray-400 text-white px-4 py-2 rounded hover:bg-gray-500 transition">
|
||||
Batal
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="bg-white shadow-md rounded-lg p-6 max-w-xl mx-auto">
|
||||
<h1 class="text-xl font-semibold text-gray-700 mb-4">✏️ Edit Guru</h1>
|
||||
|
||||
<form action="{{ route('guru.update', $guru->id) }}" method="POST">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-gray-700 mb-1">Nama</label>
|
||||
<input type="text" name="nama"
|
||||
value="{{ $guru->nama }}"
|
||||
class="w-full border rounded px-3 py-2 focus:ring focus:ring-green-300" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-gray-700 mb-1">Bidang</label>
|
||||
<input type="text" name="bidang"
|
||||
value="{{ $guru->bidang }}"
|
||||
class="w-full border rounded px-3 py-2 focus:ring focus:ring-green-300">
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-gray-700 mb-1">Telepon</label>
|
||||
<input type="text" name="telepon"
|
||||
value="{{ $guru->telepon }}"
|
||||
class="w-full border rounded px-3 py-2 focus:ring focus:ring-green-300">
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-gray-700 mb-1">Alamat</label>
|
||||
<input type="text" name="alamat"
|
||||
value="{{ $guru->alamat }}"
|
||||
class="w-full border rounded px-3 py-2 focus:ring focus:ring-green-300">
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex gap-3">
|
||||
<button type="submit"
|
||||
class="bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700 transition">
|
||||
Update
|
||||
</button>
|
||||
<a href="{{ route('guru.index') }}"
|
||||
class="bg-gray-400 text-white px-4 py-2 rounded hover:bg-gray-500 transition">
|
||||
Batal
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="bg-white shadow-md rounded-lg p-6">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h1 class="text-xl font-semibold text-gray-700">👨🏫 Data Guru</h1>
|
||||
<a href="{{ route('guru.create') }}"
|
||||
class="bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700 transition">
|
||||
+ Tambah Guru
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<table class="w-full table-auto border-collapse">
|
||||
<thead>
|
||||
<tr class="bg-green-600 text-white text-left">
|
||||
<th class="p-2">#</th>
|
||||
<th class="p-2">Nama</th>
|
||||
<th class="p-2">Bidang</th>
|
||||
<th class="p-2">Telepon</th>
|
||||
<th class="p-2">Alamat</th>
|
||||
<th class="p-2">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($guru as $i => $item)
|
||||
<tr class="border-b hover:bg-gray-50">
|
||||
<td class="p-2">{{ $i+1 }}</td>
|
||||
<td class="p-2">{{ $item->nama ?? '-' }}</td>
|
||||
<td class="p-2">{{ $item->bidang ?? '-' }}</td>
|
||||
<td class="p-2">{{ $item->telepon ?? '-' }}</td>
|
||||
<td class="p-2">{{ $item->alamat ?? '-' }}</td>
|
||||
<td class="p-2 flex gap-2">
|
||||
<a href="{{ route('guru.edit', $item->id) }}"
|
||||
class="bg-blue-500 text-white px-3 py-1 rounded hover:bg-blue-600">
|
||||
Edit
|
||||
</a>
|
||||
<form action="{{ route('guru.destroy', $item->id) }}" method="POST" onsubmit="return confirm('Yakin ingin menghapus data ini?')">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit"
|
||||
class="bg-red-500 text-white px-3 py-1 rounded hover:bg-red-600">
|
||||
Hapus
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="6" class="text-center text-gray-500 p-4">Belum ada data guru</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="max-w-xl mx-auto bg-white shadow-md rounded-lg p-6">
|
||||
<h1 class="text-xl font-semibold mb-4 text-gray-700">➕ Tambah Peserta Didik</h1>
|
||||
|
||||
<form action="{{ route('siswa.store') }}" method="POST" enctype="multipart/form-data" class="space-y-4">
|
||||
@csrf
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-600">Nama</label>
|
||||
<input type="text" name="nama" class="w-full border rounded px-3 py-2 focus:ring-2 focus:ring-green-400" required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-600">NIS</label>
|
||||
<input type="text" name="nis" class="w-full border rounded px-3 py-2 focus:ring-2 focus:ring-green-400" required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-600">Tanggal Lahir</label>
|
||||
<input type="date" name="tanggal_lahir" class="w-full border rounded px-3 py-2 focus:ring-2 focus:ring-green-400" required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-600">Kelas</label>
|
||||
<select name="kelas_id" class="w-full border rounded px-3 py-2 focus:ring-2 focus:ring-green-400" required>
|
||||
<option value="">-- Pilih Kelas --</option>
|
||||
@foreach($kelas as $k)
|
||||
<option value="{{ $k->id }}">{{ $k->nama }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-600">Wali Murid</label>
|
||||
<select name="wali_id" class="w-full border rounded px-3 py-2 focus:ring-2 focus:ring-green-400" required>
|
||||
<option value="">-- Pilih Wali Murid --</option>
|
||||
@foreach($wali as $w)
|
||||
<option value="{{ $w->id }}">{{ $w->nama }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-600">Foto</label>
|
||||
<input type="file" name="foto" class="w-full border rounded px-3 py-2 focus:ring-2 focus:ring-green-400">
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-2">
|
||||
<a href="{{ route('siswa.index') }}" class="bg-gray-300 px-4 py-2 rounded hover:bg-gray-400">Batal</a>
|
||||
<button type="submit" class="bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700">Simpan</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="max-w-xl mx-auto bg-white shadow-md rounded-lg p-6">
|
||||
<h1 class="text-xl font-semibold mb-4 text-gray-700">✏️ Edit Peserta Didik</h1>
|
||||
|
||||
<form action="{{ route('siswa.update', $siswa->id) }}" method="POST" enctype="multipart/form-data" class="space-y-4">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-600">Nama</label>
|
||||
<input type="text" name="nama" value="{{ old('nama', $siswa->nama) }}"
|
||||
class="w-full border rounded px-3 py-2 focus:ring-2 focus:ring-green-400" required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-600">NIS</label>
|
||||
<input type="text" name="nis" value="{{ old('nis', $siswa->nis) }}"
|
||||
class="w-full border rounded px-3 py-2 focus:ring-2 focus:ring-green-400" required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-600">Tanggal Lahir</label>
|
||||
<input type="date" name="tanggal_lahir" value="{{ old('tanggal_lahir', $siswa->tanggal_lahir) }}"
|
||||
class="w-full border rounded px-3 py-2 focus:ring-2 focus:ring-green-400" required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-600">Kelas</label>
|
||||
<select name="kelas_id" class="w-full border rounded px-3 py-2 focus:ring-2 focus:ring-green-400" required>
|
||||
@foreach($kelas as $k)
|
||||
<option value="{{ $k->id }}" {{ $siswa->kelas_id == $k->id ? 'selected' : '' }}>
|
||||
{{ $k->nama }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-600">Wali Murid</label>
|
||||
<select name="wali_id" class="w-full border rounded px-3 py-2 focus:ring-2 focus:ring-green-400" required>
|
||||
@foreach($wali as $w)
|
||||
<option value="{{ $w->id }}" {{ $siswa->wali_id == $w->id ? 'selected' : '' }}>
|
||||
{{ $w->nama }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-600">Foto</label>
|
||||
@if($siswa->foto)
|
||||
<div class="mb-2">
|
||||
<img src="{{ asset('storage/'.$siswa->foto) }}" class="w-24 h-24 rounded object-cover">
|
||||
</div>
|
||||
@endif
|
||||
<input type="file" name="foto" class="w-full border rounded px-3 py-2 focus:ring-2 focus:ring-green-400">
|
||||
<p class="text-xs text-gray-500 mt-1">Kosongkan jika tidak ingin mengubah foto</p>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-2">
|
||||
<a href="{{ route('siswa.index') }}" class="bg-gray-300 px-4 py-2 rounded hover:bg-gray-400">Batal</a>
|
||||
<button type="submit" class="bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700">Update</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="bg-white shadow-md rounded-lg p-6">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h1 class="text-xl font-semibold text-gray-700">📚 Data Peserta Didik</h1>
|
||||
<a href="{{ route('siswa.create') }}"
|
||||
class="bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700 transition">
|
||||
+ Tambah Siswa
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<table class="w-full table-auto border-collapse">
|
||||
<thead>
|
||||
<tr class="bg-green-600 text-white text-left">
|
||||
<th class="p-2">#</th>
|
||||
<th class="p-2">Nama</th>
|
||||
<th class="p-2">NIS</th>
|
||||
<th class="p-2">Kelas</th>
|
||||
<th class="p-2">Wali Murid</th>
|
||||
<th class="p-2">Foto</th>
|
||||
<th class="p-2">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($siswa as $i => $item)
|
||||
<tr class="border-b hover:bg-gray-50">
|
||||
<td class="p-2">{{ $i+1 }}</td>
|
||||
<td class="p-2">{{ $item->nama }}</td>
|
||||
<td class="p-2">{{ $item->nis }}</td>
|
||||
<td class="p-2">{{ $item->kelas->nama ?? '-' }}</td>
|
||||
<td class="p-2">{{ $item->wali->nama ?? '-' }}</td>
|
||||
<td class="p-2">
|
||||
@if($item->foto)
|
||||
<img src="{{ asset('storage/'.$item->foto) }}"
|
||||
class="w-12 h-12 rounded object-cover">
|
||||
@else
|
||||
<span class="text-gray-400">-</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="p-2 flex gap-2">
|
||||
<a href="{{ route('siswa.edit', $item->id) }}"
|
||||
class="bg-blue-500 text-white px-3 py-1 rounded hover:bg-blue-600">
|
||||
Edit
|
||||
</a>
|
||||
<form action="{{ route('siswa.destroy', $item->id) }}" method="POST" onsubmit="return confirm('Yakin ingin menghapus?')">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit"
|
||||
class="bg-red-500 text-white px-3 py-1 rounded hover:bg-red-600">
|
||||
Hapus
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="7" class="text-center text-gray-500 p-4">Belum ada data siswa</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="bg-white p-6 rounded-lg shadow w-1/2 mx-auto">
|
||||
<h2 class="text-xl font-semibold mb-4">Tambah Wali Murid</h2>
|
||||
|
||||
<form action="{{ route('wali.store') }}" method="POST">
|
||||
@csrf
|
||||
<div class="mb-4">
|
||||
<label class="block mb-1">Nama</label>
|
||||
<input type="text" name="nama" class="w-full border rounded p-2" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block mb-1">Alamat</label>
|
||||
<input type="text" name="alamat" class="w-full border rounded p-2">
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block mb-1">Lokasi Latitude</label>
|
||||
<input type="text" name="lokasi_lat" class="w-full border rounded p-2">
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block mb-1">Lokasi Longitude</label>
|
||||
<input type="text" name="lokasi_lng" class="w-full border rounded p-2">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700">Simpan</button>
|
||||
<a href="{{ route('wali.index') }}" class="ml-2 px-4 py-2 bg-gray-300 rounded">Batal</a>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="bg-white p-6 rounded-lg shadow w-1/2 mx-auto">
|
||||
<h2 class="text-xl font-semibold mb-4">Edit Wali Murid</h2>
|
||||
|
||||
<form action="{{ route('wali.update', $wali->id) }}" method="POST">
|
||||
@csrf @method('PUT')
|
||||
<div class="mb-4">
|
||||
<label class="block mb-1">Nama</label>
|
||||
<input type="text" name="nama" class="w-full border rounded p-2" value="{{ $wali->nama }}" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block mb-1">Alamat</label>
|
||||
<input type="text" name="alamat" class="w-full border rounded p-2" value="{{ $wali->alamat }}">
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block mb-1">Lokasi Latitude</label>
|
||||
<input type="text" name="lokasi_lat" class="w-full border rounded p-2" value="{{ $wali->lokasi_lat }}">
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block mb-1">Lokasi Longitude</label>
|
||||
<input type="text" name="lokasi_lng" class="w-full border rounded p-2" value="{{ $wali->lokasi_lng }}">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700">Update</button>
|
||||
<a href="{{ route('wali.index') }}" class="ml-2 px-4 py-2 bg-gray-300 rounded">Batal</a>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="bg-white shadow-md rounded-lg p-6">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h1 class="text-xl font-semibold text-gray-700">👪 Data Wali Murid</h1>
|
||||
<a href="{{ route('wali.create') }}"
|
||||
class="bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700 transition">
|
||||
+ Tambah Wali Murid
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<table class="w-full table-auto border-collapse">
|
||||
<thead>
|
||||
<tr class="bg-green-600 text-white text-left">
|
||||
<th class="p-2">#</th>
|
||||
<th class="p-2">Nama</th>
|
||||
<th class="p-2">Alamat</th>
|
||||
<th class="p-2">Lokasi (Lat, Lng)</th>
|
||||
<th class="p-2">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($wali as $i => $item)
|
||||
<tr class="border-b hover:bg-gray-50">
|
||||
<td class="p-2">{{ $i+1 }}</td>
|
||||
<td class="p-2">{{ $item->nama ?? '-' }}</td>
|
||||
<td class="p-2">{{ $item->alamat ?? '-' }}</td>
|
||||
<td class="p-2">
|
||||
{{ $item->lokasi_lat ?? '-' }}, {{ $item->lokasi_lng ?? '-' }}
|
||||
</td>
|
||||
<td class="p-2 flex gap-2">
|
||||
<a href="{{ route('wali.edit', $item->id) }}"
|
||||
class="bg-blue-500 text-white px-3 py-1 rounded hover:bg-blue-600">
|
||||
Edit
|
||||
</a>
|
||||
<form action="{{ route('wali.destroy', $item->id) }}" method="POST" onsubmit="return confirm('Yakin ingin menghapus data ini?')">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit"
|
||||
class="bg-red-500 text-white px-3 py-1 rounded hover:bg-red-600">
|
||||
Hapus
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="5" class="text-center text-gray-500 p-4">Belum ada data wali murid</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -20,9 +20,9 @@
|
|||
<div>
|
||||
<p class="font-semibold uppercase text-xs mb-2">Data Master</p>
|
||||
<ul class="ml-4 space-y-1">
|
||||
<li><a href="#" class="block p-2 hover:bg-green-700 rounded">👨🏫 Guru</a></li>
|
||||
<li><a href="#" class="block p-2 hover:bg-green-700 rounded">👪 Wali Murid</a></li>
|
||||
<li><a href="#" class="block p-2 hover:bg-green-700 rounded">🧒 Peserta Didik</a></li>
|
||||
<li><a href="{{ route('guru.index') }}" class="block p-2 hover:bg-green-700 rounded">👨🏫 Guru</a></li>
|
||||
<li><a href="{{ route('wali.index') }}" class="block p-2 hover:bg-green-700 rounded">👪 Wali Murid</a></li>
|
||||
<li><a href="{{ route('siswa.index') }}" class="block p-2 hover:bg-green-700 rounded">🧒 Peserta Didik</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,26 @@
|
|||
|
||||
// pilih salah satu (saya sarankan pakai apiResource biar singkat)
|
||||
Route::apiResource('kelas', KelasController::class);
|
||||
Route::apiResource('guru', GuruController::class);
|
||||
Route::apiResource('wali', WaliMuridController::class);
|
||||
Route::apiResource('siswa', SiswaController::class);
|
||||
Route::apiResource('guru', GuruController::class)->names([
|
||||
'index' => 'api.guru.index',
|
||||
'show' => 'api.guru.show',
|
||||
'store' => 'api.guru.store',
|
||||
'update' => 'api.guru.update',
|
||||
'destroy' => 'api.guru.destroy',
|
||||
]);
|
||||
Route::apiResource('wali', WaliMuridController::class)->names([
|
||||
'index' => 'api.wali.index',
|
||||
'show' => 'api.wali.show',
|
||||
'store' => 'api.wali.store',
|
||||
'update' => 'api.wali.update',
|
||||
'destroy' => 'api.wali.destroy',
|
||||
]);
|
||||
Route::apiResource('siswa', SiswaController::class)->names([
|
||||
'index' => 'api.siswa.index',
|
||||
'show' => 'api.siswa.show',
|
||||
'store' => 'api.siswa.store',
|
||||
'update' => 'api.siswa.update',
|
||||
'destroy' => 'api.siswa.destroy',
|
||||
]);
|
||||
|
||||
});
|
||||
|
|
@ -3,6 +3,9 @@
|
|||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\AuthController;
|
||||
use App\Http\Controllers\DashboardController;
|
||||
use App\Http\Controllers\Admin\GuruController;
|
||||
use App\Http\Controllers\Admin\WaliMuridController;
|
||||
use App\Http\Controllers\Admin\SiswaController;
|
||||
|
||||
// Login routes
|
||||
Route::get('/login', [AuthController::class, 'showLogin'])->name('login');
|
||||
|
|
@ -17,4 +20,10 @@
|
|||
// Hanya bisa diakses setelah login
|
||||
Route::middleware('auth')->group(function () {
|
||||
Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
|
||||
});
|
||||
|
||||
Route::prefix('admin')->group(function () {
|
||||
Route::resource('guru', GuruController::class);
|
||||
Route::resource('wali', WaliMuridController::class);
|
||||
Route::resource('siswa', SiswaController::class);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue