diff --git a/app/Http/Controllers/Admin/WaliMuridController.php b/app/Http/Controllers/Admin/WaliMuridController.php index 85a46bd..59657e4 100644 --- a/app/Http/Controllers/Admin/WaliMuridController.php +++ b/app/Http/Controllers/Admin/WaliMuridController.php @@ -4,63 +4,57 @@ use App\Http\Controllers\Controller; use App\Models\WaliMurid; -use App\Models\User; use Illuminate\Http\Request; class WaliMuridController extends Controller { public function index() { - // ambil semua wali murid + user terkait - $wali = WaliMurid::with('user')->get(); - return view('admin.wali.index', compact('wali')); + $wali_murids = WaliMurid::orderBy('created_at', 'desc')->get(); + return view('admin.wali_murid.index', compact('wali_murids')); } 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')); + return view('admin.wali_murid.create'); } public function store(Request $request) { $request->validate([ - 'nama' => 'required|string|max:255', - 'alamat' => 'nullable|string', - 'lokasi_lat' => 'nullable|numeric', - 'lokasi_lng' => 'nullable|numeric', + 'nama_wali' => 'required|string|max:100', + 'email' => 'nullable|email|max:100', + 'no_hp' => 'nullable|string|max:20', + 'alamat' => 'nullable|string|max:255', ]); - - WaliMurid::create($request->all()); - - return redirect()->route('wali.index')->with('success', 'Wali Murid berhasil ditambahkan'); + + WaliMurid::create($request->only(['nama_wali', 'email', 'no_hp', 'alamat'])); + + return redirect()->route('wali-murid.index')->with('success', 'Data wali murid berhasil ditambahkan.'); } - - public function edit(WaliMurid $wali) + public function edit(WaliMurid $wali_murid) { - $users = User::where('role', 'wali')->get(); - return view('admin.wali.edit', compact('wali', 'users')); + return view('admin.wali_murid.edit', compact('wali_murid')); } - public function update(Request $request, WaliMurid $wali) + public function update(Request $request, WaliMurid $wali_murid) { $request->validate([ - 'nama' => 'required|string|max:255', - 'alamat' => 'nullable|string', - 'lokasi_lat' => 'nullable|numeric', - 'lokasi_lng' => 'nullable|numeric', + 'nama_wali' => 'required|string|max:100', + 'email' => 'nullable|email|max:100', + 'no_hp' => 'nullable|string|max:20', + 'alamat' => 'nullable|string|max:255', ]); - $wali->update($request->all()); + $wali_murid->update($request->all()); - return redirect()->route('wali.index')->with('success', 'Wali Murid berhasil diperbarui'); + return redirect()->route('wali-murid.index')->with('success', 'Data wali murid berhasil diperbarui.'); } - public function destroy(WaliMurid $wali) + public function destroy(WaliMurid $wali_murid) { - $wali->delete(); + $wali_murid->delete(); - return redirect()->route('wali.index')->with('success', 'Wali Murid berhasil dihapus'); + return redirect()->route('wali-murid.index')->with('success', 'Data wali murid berhasil dihapus.'); } } diff --git a/app/Models/WaliMurid.php b/app/Models/WaliMurid.php index 7b8cb22..362bb8e 100644 --- a/app/Models/WaliMurid.php +++ b/app/Models/WaliMurid.php @@ -2,21 +2,19 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class WaliMurid extends Model { + use HasFactory; + protected $table = 'wali_murids'; - protected $fillable = ['user_id','alamat','lokasi_lat','lokasi_lng']; - - public function user() - { - return $this->belongsTo(User::class); - } - - public function siswa() - { - return $this->hasMany(Siswa::class,'wali_id'); - } -} \ No newline at end of file + protected $fillable = [ + 'nama_wali', + 'email', + 'no_hp', + 'alamat', + ]; +} diff --git a/resources/views/admin/guru/create.blade.php b/resources/views/admin/guru/create.blade.php index 268705b..d82a5ec 100644 --- a/resources/views/admin/guru/create.blade.php +++ b/resources/views/admin/guru/create.blade.php @@ -6,40 +6,28 @@
@csrf +
- - + +
- - + +
- - + +
- - + +
-
- - - Batal - -
+
@endsection diff --git a/resources/views/admin/guru/edit.blade.php b/resources/views/admin/guru/edit.blade.php index 57b8e42..a9777cd 100644 --- a/resources/views/admin/guru/edit.blade.php +++ b/resources/views/admin/guru/edit.blade.php @@ -9,43 +9,26 @@ @method('PUT')
- - + +
- - + +
- - + +
- - + +
-
- - - Batal - -
+ @endsection diff --git a/resources/views/admin/guru/index.blade.php b/resources/views/admin/guru/index.blade.php index aa5ece8..05a0f2c 100644 --- a/resources/views/admin/guru/index.blade.php +++ b/resources/views/admin/guru/index.blade.php @@ -1,43 +1,44 @@ -@extends('layouts.admin') +@extends('layouts.app') @section('content') -
-

📚 Data Guru

+
+
+

👨‍🏫 Data Guru

+ + Tambah Guru +
- + Tambah Guru - - - - - - - - - - +
NoNama GuruEmailNo HPBidangAksi
+ + + + + + + + - @forelse ($gurus as $guru) - - - - - - - - + @forelse ($gurus as $i => $guru) + + + + + + + + @empty - - - + + + @endforelse
#Nama GuruEmailNo HPBidangAksi
{{ $loop->iteration }}{{ $guru->nama_guru }}{{ $guru->email }}{{ $guru->no_hp }}{{ $guru->bidang }} - Edit -
- @csrf - @method('DELETE') - -
-
{{ $i + 1 }}{{ $guru->nama_guru ?? '-' }}{{ $guru->email ?? '-' }}{{ $guru->no_hp ?? '-' }}{{ $guru->bidang ?? '-' }} + Edit +
+ @csrf + @method('DELETE') + +
+
Belum ada data guru
Belum ada data guru
diff --git a/resources/views/admin/wali/create.blade.php b/resources/views/admin/wali/create.blade.php index 7b8830d..d1a3f09 100644 --- a/resources/views/admin/wali/create.blade.php +++ b/resources/views/admin/wali/create.blade.php @@ -1,33 +1,33 @@ @extends('layouts.app') @section('content') -
-

Tambah Wali Murid

+
+

➕ Tambah Wali Murid

-
+ @csrf +
- - + +
- - + +
- - + +
- - + +
- - Batal +
@endsection diff --git a/resources/views/admin/wali/edit.blade.php b/resources/views/admin/wali/edit.blade.php index 96953b9..f036913 100644 --- a/resources/views/admin/wali/edit.blade.php +++ b/resources/views/admin/wali/edit.blade.php @@ -1,33 +1,34 @@ @extends('layouts.app') @section('content') -
-

Edit Wali Murid

+
+

✏️ Edit Wali Murid

+ +
+ @csrf + @method('PUT') - - @csrf @method('PUT')
- - + +
- - + +
- - + +
- - + +
- - Batal +
@endsection diff --git a/resources/views/admin/wali/index.blade.php b/resources/views/admin/wali/index.blade.php index 03d2900..76e4d74 100644 --- a/resources/views/admin/wali/index.blade.php +++ b/resources/views/admin/wali/index.blade.php @@ -3,8 +3,8 @@ @section('content')
-

👪 Data Wali Murid

- 👨‍👩‍👧 Data Wali Murid + + Tambah Wali Murid @@ -14,39 +14,33 @@ class="bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700 transition"> # - Nama + Nama Wali Murid + Email + No HP Alamat - Lokasi (Lat, Lng) Aksi - @forelse ($wali as $i => $item) + @forelse($wali_murids as $i => $wali) - {{ $i+1 }} - {{ $item->nama ?? '-' }} - {{ $item->alamat ?? '-' }} - - {{ $item->lokasi_lat ?? '-' }}, {{ $item->lokasi_lng ?? '-' }} - - - - Edit - -
+ {{ $i + 1 }} + {{ $wali->nama_wali ?? '-' }} + {{ $wali->email ?? '-' }} + {{ $wali->no_hp ?? '-' }} + {{ $wali->alamat ?? '-' }} + + Edit + @csrf @method('DELETE') - +
@empty - Belum ada data wali murid + Belum ada data wali murid. @endforelse diff --git a/resources/views/admin/wali_murid/create.blade.php b/resources/views/admin/wali_murid/create.blade.php new file mode 100644 index 0000000..7ce29a3 --- /dev/null +++ b/resources/views/admin/wali_murid/create.blade.php @@ -0,0 +1,36 @@ +@extends('layouts.app') + +@section('content') +
+

Tambah Data Wali Murid

+ +
+ @csrf + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ Batal + +
+
+
+@endsection diff --git a/resources/views/admin/wali_murid/edit.blade.php b/resources/views/admin/wali_murid/edit.blade.php new file mode 100644 index 0000000..bd689b1 --- /dev/null +++ b/resources/views/admin/wali_murid/edit.blade.php @@ -0,0 +1,37 @@ +@extends('layouts.app') + +@section('content') +
+

Edit Data Wali Murid

+ +
+ @csrf + @method('PUT') + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ Batal + +
+
+
+@endsection diff --git a/resources/views/admin/wali_murid/index.blade.php b/resources/views/admin/wali_murid/index.blade.php new file mode 100644 index 0000000..2f27586 --- /dev/null +++ b/resources/views/admin/wali_murid/index.blade.php @@ -0,0 +1,47 @@ +@extends('layouts.app') + +@section('content') +
+
+

+ 👨‍👩‍👧 Data Wali Murid +

+ + Tambah Wali Murid +
+ + + + + + + + + + + + + @forelse ($wali_murids as $wali) + + + + + + + + + @empty + + + + @endforelse + +
#Nama WaliEmailNo HPAlamatAksi
{{ $loop->iteration }}{{ $wali->nama_wali }}{{ $wali->email }}{{ $wali->no_hp }}{{ $wali->alamat }} + Edit +
+ @csrf + @method('DELETE') + +
+
Belum ada data wali murid.
+
+@endsection diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index c61d883..f37355d 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -21,7 +21,7 @@

Data Master

@@ -70,6 +70,11 @@ class="px-4 py-2 rounded-lg border focus:ring-2 focus:ring-green-400 w-72 text-s
@yield('content') + @if (session('success')) +
+ {{ session('success') }} +
+ @endif
diff --git a/routes/api.php b/routes/api.php index 6a31ce9..156223e 100644 --- a/routes/api.php +++ b/routes/api.php @@ -29,7 +29,7 @@ 'destroy' => 'api.guru.destroy', ]); Route::apiResource('wali', WaliMuridController::class)->names([ - 'index' => 'api.wali.index', + 'index' => 'api.wali-murid.index', 'show' => 'api.wali.show', 'store' => 'api.wali.store', 'update' => 'api.wali.update', diff --git a/routes/web.php b/routes/web.php index bdd2745..eabcb19 100644 --- a/routes/web.php +++ b/routes/web.php @@ -26,7 +26,7 @@ Route::prefix('admin')->group(function () { Route::resource('guru', GuruController::class); - Route::resource('wali', WaliMuridController::class); + Route::resource('wali-murid', WaliMuridController::class); Route::resource('siswa', SiswaController::class); Route::middleware(['auth'])->group(function () {