update guru
This commit is contained in:
parent
822b613cb1
commit
409c182eb4
|
@ -8,7 +8,57 @@
|
|||
class GuruController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
$guru = Guru::select('id', 'nama_guru', 'jabatan', 'no_hp_guru', 'email_guru')->get();
|
||||
return view('admin.guru', compact('guru'));
|
||||
$guru = Guru::all();
|
||||
return view('admin.guru.index', compact('guru'));
|
||||
}
|
||||
|
||||
public function create(){
|
||||
return view('admin.guru.create');
|
||||
}
|
||||
|
||||
public function store(Request $request){
|
||||
$request->validate([
|
||||
'nama_guru' => 'required|string|max:255',
|
||||
'jabatan' => 'required|string|max:255',
|
||||
'no_hp_guru' => 'required|numeric',
|
||||
'email_guru' => 'required|email|unique:guru,email_guru',
|
||||
]);
|
||||
|
||||
Guru::create([
|
||||
'nama_guru' => $request->nama_guru,
|
||||
'jabatan' => $request->jabatan,
|
||||
'no_hp_guru' => $request->no_hp_guru,
|
||||
'email_guru' => $request->email_guru
|
||||
]);
|
||||
|
||||
return redirect()->route('admin.guru.index')->with('success', 'Guru berhasil ditambahkan');
|
||||
}
|
||||
|
||||
public function edit($id){
|
||||
$guru = Guru::findOrFail($id);
|
||||
return view('admin.guru.edit', compact('guru'));
|
||||
}
|
||||
|
||||
public function update(Request $request, Guru $guru){
|
||||
$request->validate([
|
||||
'nama_guru' => 'required|string|max:255',
|
||||
'jabatan' => 'required|string|max:255',
|
||||
'no_hp_guru' => 'required|numeric',
|
||||
'email_guru' => 'required|email|unique:guru,email_guru,' . $guru->id,
|
||||
]);
|
||||
|
||||
$guru->update([
|
||||
'nama_guru' => $request->nama_guru,
|
||||
'jabatan' => $request->jabatan,
|
||||
'no_hp_guru' => $request->no_hp_guru,
|
||||
'email_guru' => $request->email_guru
|
||||
]);
|
||||
|
||||
return redirect()->route('admin.guru.index')->with('success', 'Guru berhasil di update');
|
||||
}
|
||||
|
||||
public function destroy(Guru $guru){
|
||||
$guru->delete();
|
||||
return redirect()->route('admin.guru.index')->with('success', 'Guru berhasil dihapus');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,8 @@ public function run(): void
|
|||
JurusanSeeder::class,
|
||||
KelasSeeder::class,
|
||||
SiswaTableSeeder::class,
|
||||
StatusSeeder::class
|
||||
StatusSeeder::class,
|
||||
GuruSeeder::class
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Guru;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class GuruSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
Guru::insert([
|
||||
[
|
||||
'nama_guru' => 'Ridwan',
|
||||
'jabatan' => 'Guru',
|
||||
'no_hp_guru' => '081234567',
|
||||
'email_guru' => 'ridwan@gmail'
|
||||
],
|
||||
[
|
||||
'nama_guru' => 'Jamal',
|
||||
'jabatan' => 'Guru',
|
||||
'no_hp_guru' => '0891238217',
|
||||
'email_guru' => 'jamal@gmail'
|
||||
],
|
||||
[
|
||||
'nama_guru' => 'Budi Speed',
|
||||
'jabatan' => 'Guru',
|
||||
'no_hp_guru' => '08192312',
|
||||
'email_guru' => 'Budi Speed@gmail'
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -3221,17 +3221,17 @@
|
|||
"license": "MIT"
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.2.tgz",
|
||||
"integrity": "sha512-ZSvGOXKGceizRQIZSz7TGJ0pS3QLlVY/9hwxVh17W3re67je1RKYzFHivZ/t0tubU78Vkyb9WnHPENSBCzbckg==",
|
||||
"version": "6.3.5",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz",
|
||||
"integrity": "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.25.0",
|
||||
"fdir": "^6.4.3",
|
||||
"fdir": "^6.4.4",
|
||||
"picomatch": "^4.0.2",
|
||||
"postcss": "^8.5.3",
|
||||
"rollup": "^4.34.9",
|
||||
"tinyglobby": "^0.2.12"
|
||||
"tinyglobby": "^0.2.13"
|
||||
},
|
||||
"bin": {
|
||||
"vite": "bin/vite.js"
|
||||
|
|
|
@ -40,7 +40,7 @@ class="dropdown-btn w-full text-left p-2 bg-gray-100 rounded-lg flex justify-bet
|
|||
<li><a href="{{ route('admin.siswa.index') }}"
|
||||
class="block p-2 rounded-lg {{ request()->is('admin/siswa') ? 'bg-blue-100 text-blue-600' : 'bg-gray-50 text-gray-800' }}">Siswa</a>
|
||||
</li>
|
||||
<li><a href="{{ route('admin.guru') }}"
|
||||
<li><a href="{{ route('admin.guru.index') }}"
|
||||
class="block p-2 rounded-lg {{ request()->is('admin/guru') ? 'bg-blue-100 text-blue-600' : 'bg-gray-50 text-gray-800' }}">Guru</a>
|
||||
</li>
|
||||
<li><a href="{{ route('admin.kelas.index') }}"
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
@extends('layouts.dashboard')
|
||||
|
||||
@section('title', 'Smart School | Guru')
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="bg-white shadow-md rounded-lg p-6">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h1 class="text-2xl font-semibold">Data Guru</h1>
|
||||
<a href="{{ route('siswa.create') }}" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg">
|
||||
+ Tambah Guru
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full border-collapse border border-gray-200">
|
||||
<thead class="bg-gray-100">
|
||||
<tr class="text-left text-gray-700">
|
||||
<th class="border px-4 py-2">No</th>
|
||||
<th class="border px-4 py-2">Nama Guru</th>
|
||||
<th class="border px-4 py-2">Jabatan</th>
|
||||
<th class="border px-4 py-2">No HP</th>
|
||||
<th class="border px-4 py-2">Email</th>
|
||||
<th class="border px-4 py-2 text-center">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($guru as $index => $item)
|
||||
<tr class="border hover:bg-gray-50">
|
||||
<td class="border px-4 py-2">{{ $index + 1 }}</td>
|
||||
<td class="border px-4 py-2">{{ $item->nama_guru }}</td>
|
||||
<td class="border px-4 py-2">{{ $item->jabatan }}</td>
|
||||
<td class="border px-4 py-2">{{ $item->no_hp_guru }}</td>
|
||||
<td class="border px-4 py-2">{{ $item->email_guru }}</td>
|
||||
<td class="border px-4 py-2 text-center">
|
||||
<a href="{{ route('siswa.edit', $item->id) }}" class="bg-yellow-400 hover:bg-yellow-500 text-white px-3 py-1 rounded">Edit</a>
|
||||
<form action="{{ route('siswa.destroy', $item->id) }}" method="POST" class="inline-block">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" onclick="return confirm('Yakin ingin menghapus?')" class="bg-red-500 hover:bg-red-600 text-white px-3 py-1 rounded">
|
||||
Hapus
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
|
@ -0,0 +1,136 @@
|
|||
@extends('layouts.dashboard')
|
||||
|
||||
@section('title', 'Smart School | Tambah Guru')
|
||||
|
||||
@section('content')
|
||||
<div class="container mx-auto px-4 py-8">
|
||||
<!-- Header Section -->
|
||||
<div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-8 gap-4">
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold text-gray-800">Tambah Guru Baru</h1>
|
||||
<div class="flex items-center mt-2">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-blue-500 mr-1" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2h-1V9z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<p class="text-sm text-gray-600">Tambahkan data guru baru ke sistem</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="{{ route('admin.guru.index') }}"
|
||||
class="bg-gradient-to-r from-gray-200 to-gray-300 hover:from-gray-300 hover:to-gray-400 text-gray-800 px-6 py-3 rounded-lg flex items-center transition duration-300 shadow-md hover:shadow-lg">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fill-rule="evenodd" d="M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
Kembali ke Daftar
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Form Card -->
|
||||
<div class="bg-white rounded-xl shadow-lg overflow-hidden max-w-3xl mx-auto">
|
||||
<!-- Card Header -->
|
||||
<div class="bg-gradient-to-r from-blue-600 to-blue-800 px-6 py-4">
|
||||
<h2 class="text-xl font-semibold text-white flex items-center">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fill-rule="evenodd" d="M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
Form Tambah Guru
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<!-- Form Content -->
|
||||
<div class="p-6">
|
||||
<form id="createForm" action="{{ route('admin.guru.store') }}" method="POST">
|
||||
@csrf
|
||||
|
||||
<!-- Nama Guru -->
|
||||
<div class="mb-6">
|
||||
<label for="nama_guru" class="block text-sm font-medium text-gray-700 mb-2">Nama Guru <span class="text-red-500">*</span></label>
|
||||
<input type="text" name="nama_guru" id="nama_guru"
|
||||
class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:border-blue-500 focus:ring-2 focus:ring-blue-200 transition duration-300 @error('nama_guru') border-red-500 @enderror"
|
||||
value="{{ old('nama_guru') }}"
|
||||
placeholder="Contoh: Budi Santoso" required>
|
||||
@error('nama_guru')
|
||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<!-- Jabatan -->
|
||||
<div class="mb-6">
|
||||
<label for="jabatan" class="block text-sm font-medium text-gray-700 mb-2">Jabatan <span class="text-red-500">*</span></label>
|
||||
<input type="text" name="jabatan" id="jabatan"
|
||||
class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:border-blue-500 focus:ring-2 focus:ring-blue-200 transition duration-300 @error('jabatan') border-red-500 @enderror"
|
||||
value="{{ old('jabatan') }}"
|
||||
placeholder="Contoh: Kepala Sekolah" required>
|
||||
@error('jabatan')
|
||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<!-- No HP -->
|
||||
<div class="mb-6">
|
||||
<label for="no_hp_guru" class="block text-sm font-medium text-gray-700 mb-2">No. HP <span class="text-red-500">*</span></label>
|
||||
<input type="text" name="no_hp_guru" id="no_hp_guru"
|
||||
class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:border-blue-500 focus:ring-2 focus:ring-blue-200 transition duration-300 @error('no_hp_guru') border-red-500 @enderror"
|
||||
value="{{ old('no_hp_guru') }}"
|
||||
placeholder="Contoh: 081234567890" required>
|
||||
@error('no_hp_guru')
|
||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<!-- Email -->
|
||||
<div class="mb-6">
|
||||
<label for="email_guru" class="block text-sm font-medium text-gray-700 mb-2">Email <span class="text-red-500">*</span></label>
|
||||
<input type="email" name="email_guru" id="email_guru"
|
||||
class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:border-blue-500 focus:ring-2 focus:ring-blue-200 transition duration-300 @error('email_guru') border-red-500 @enderror"
|
||||
value="{{ old('email_guru') }}"
|
||||
placeholder="Contoh: guru@example.com" required>
|
||||
@error('email_guru')
|
||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<div class="flex justify-end space-x-4 pt-6 border-t border-gray-200">
|
||||
<button type="reset"
|
||||
class="px-6 py-2.5 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-100 transition duration-300 flex items-center shadow-sm hover:shadow-md">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
Reset
|
||||
</button>
|
||||
<button type="button" onclick="confirmCreate()"
|
||||
class="bg-gradient-to-r from-blue-600 to-blue-800 hover:from-blue-700 hover:to-blue-900 text-white px-6 py-2.5 rounded-lg transition duration-300 shadow-lg hover:shadow-xl flex items-center">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
Simpan Guru
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Include SweetAlert2 -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
<script>
|
||||
function confirmCreate() {
|
||||
Swal.fire({
|
||||
title: 'Apakah data sudah benar?',
|
||||
text: "Pastikan semua data guru telah terisi dengan benar.",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#1d4ed8',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Ya, Simpan!',
|
||||
cancelButtonText: 'Batal'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
document.getElementById('createForm').submit();
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@endsection
|
|
@ -0,0 +1,109 @@
|
|||
@extends('layouts.dashboard')
|
||||
|
||||
@section('title', 'Smart School | Edit Guru')
|
||||
|
||||
@section('content')
|
||||
<div class="container mx-auto px-4 py-8">
|
||||
<!-- Header Section -->
|
||||
<div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-8 gap-4">
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold text-gray-800">Edit Data Guru</h1>
|
||||
<div class="flex items-center mt-2">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-blue-500 mr-1" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2h-1V9z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<p class="text-sm text-gray-600">Ubah informasi guru yang sudah ada</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="{{ route('admin.guru.index') }}"
|
||||
class="bg-gradient-to-r from-gray-200 to-gray-300 hover:from-gray-300 hover:to-gray-400 text-gray-800 px-6 py-3 rounded-lg flex items-center transition duration-300 shadow-md hover:shadow-lg">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fill-rule="evenodd" d="M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
Kembali ke Daftar
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Form Card -->
|
||||
<div class="bg-white rounded-xl shadow-lg overflow-hidden max-w-3xl mx-auto">
|
||||
<!-- Card Header -->
|
||||
<div class="bg-gradient-to-r from-blue-600 to-blue-800 px-6 py-4">
|
||||
<h2 class="text-xl font-semibold text-white flex items-center">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path d="M17.414 2.586a2 2 0 00-2.828 0L7 10.172V13h2.828l7.586-7.586a2 2 0 000-2.828z"/>
|
||||
<path fill-rule="evenodd" d="M2 15a2 2 0 012-2h4a1 1 0 010 2H4v2h12v-4h2v4a2 2 0 01-2 2H4a2 2 0 01-2-2v-2z" clip-rule="evenodd"/>
|
||||
</svg>
|
||||
Form Edit Guru
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<!-- Form Content -->
|
||||
<div class="p-6">
|
||||
<form id="editForm" action="{{ route('admin.guru.update', $guru->id) }}" method="POST">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
<!-- Nama Guru -->
|
||||
<div class="mb-6">
|
||||
<label for="nama_guru" class="block text-sm font-medium text-gray-700 mb-2">Nama Guru <span class="text-red-500">*</span></label>
|
||||
<input type="text" name="nama_guru" id="nama_guru"
|
||||
class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:border-yellow-500 focus:ring-2 focus:ring-yellow-200 transition duration-300 @error('nama_guru') border-red-500 @enderror"
|
||||
value="{{ old('nama_guru', $guru->nama_guru) }}" required>
|
||||
@error('nama_guru')
|
||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<!-- Jabatan -->
|
||||
<div class="mb-6">
|
||||
<label for="jabatan" class="block text-sm font-medium text-gray-700 mb-2">Jabatan <span class="text-red-500">*</span></label>
|
||||
<input type="text" name="jabatan" id="jabatan"
|
||||
class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:border-yellow-500 focus:ring-2 focus:ring-yellow-200 transition duration-300 @error('jabatan') border-red-500 @enderror"
|
||||
value="{{ old('jabatan', $guru->jabatan) }}" required>
|
||||
@error('jabatan')
|
||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<!-- Nomor HP -->
|
||||
<div class="mb-6">
|
||||
<label for="no_hp_guru" class="block text-sm font-medium text-gray-700 mb-2">No. HP Guru <span class="text-red-500">*</span></label>
|
||||
<input type="text" name="no_hp_guru" id="no_hp_guru"
|
||||
class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:border-yellow-500 focus:ring-2 focus:ring-yellow-200 transition duration-300 @error('no_hp_guru') border-red-500 @enderror"
|
||||
value="{{ old('no_hp_guru', $guru->no_hp_guru) }}" required>
|
||||
@error('no_hp_guru')
|
||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<!-- Email -->
|
||||
<div class="mb-6">
|
||||
<label for="email_guru" class="block text-sm font-medium text-gray-700 mb-2">Email Guru <span class="text-red-500">*</span></label>
|
||||
<input type="email" name="email_guru" id="email_guru"
|
||||
class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:border-yellow-500 focus:ring-2 focus:ring-yellow-200 transition duration-300 @error('email_guru') border-red-500 @enderror"
|
||||
value="{{ old('email_guru', $guru->email_guru) }}" required>
|
||||
@error('email_guru')
|
||||
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<div class="flex justify-end space-x-4 pt-6 border-t border-gray-200">
|
||||
<a href="{{ route('admin.guru.index') }}"
|
||||
class="px-6 py-2.5 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-100 transition duration-300 flex items-center shadow-sm hover:shadow-md">
|
||||
Batal
|
||||
</a>
|
||||
<button type="submit"
|
||||
class="bg-gradient-to-r from-blue-600 to-blue-800 hover:from-blue-700 hover:to-blue-900 text-white px-6 py-2.5 rounded-lg transition duration-300 shadow-lg hover:shadow-xl flex items-center">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
Simpan Perubahan
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
|
@ -0,0 +1,80 @@
|
|||
@extends('layouts.dashboard')
|
||||
|
||||
@section('title', 'Smart School | Guru')
|
||||
|
||||
@section('content')
|
||||
<div class="container mx-auto px-4 py-8">
|
||||
<!-- Header -->
|
||||
<div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-8 gap-4">
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold text-gray-800">Manajemen Guru</h1>
|
||||
<div class="flex items-center mt-2 text-sm text-gray-600">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-blue-500 mr-1" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2h-1V9z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
Kelola data guru dan informasi kontaknya
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="{{ route('admin.guru.create') }}" class="bg-gradient-to-r from-blue-600 to-blue-800 hover:from-blue-700 hover:to-blue-900 text-white px-6 py-3 rounded-lg flex items-center transition duration-300 shadow-lg hover:shadow-xl">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fill-rule="evenodd" d="M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
Tambah Guru
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Table Card -->
|
||||
<div class="bg-white rounded-xl shadow-lg overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-200 bg-gradient-to-r from-gray-50 to-white">
|
||||
<h2 class="text-lg font-semibold text-gray-800">Daftar Guru</h2>
|
||||
<p class="text-sm text-gray-500">Data guru yang terdaftar di sistem</p>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full table-auto border-collapse">
|
||||
<thead class="bg-gray-100 text-gray-700 text-sm font-semibold">
|
||||
<tr>
|
||||
<th class="border px-6 py-3 text-left">No</th>
|
||||
<th class="border px-6 py-3 text-left">Nama Guru</th>
|
||||
<th class="border px-6 py-3 text-left">Jabatan</th>
|
||||
<th class="border px-6 py-3 text-left">No HP</th>
|
||||
<th class="border px-6 py-3 text-left">Email</th>
|
||||
<th class="border px-6 py-3 text-center">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-sm text-gray-700">
|
||||
@foreach ($guru as $index => $item)
|
||||
<tr class="hover:bg-gray-50 transition duration-200">
|
||||
<td class="border px-6 py-3">{{ $index + 1 }}</td>
|
||||
<td class="border px-6 py-3">{{ $item->nama_guru }}</td>
|
||||
<td class="border px-6 py-3">{{ $item->jabatan }}</td>
|
||||
<td class="border px-6 py-3">{{ $item->no_hp_guru }}</td>
|
||||
<td class="border px-6 py-3">{{ $item->email_guru }}</td>
|
||||
<td class="border px-6 py-3 text-center space-x-2">
|
||||
<a href="{{ route('admin.guru.edit', $item->id) }}" class="inline-block bg-blue-600 hover:bg-blue-600 text-white px-3 py-1 rounded transition duration-200">
|
||||
Edit
|
||||
</a>
|
||||
<form action="{{ route('admin.guru.destroy', $item->id) }}" method="POST" class="inline-block" onsubmit="return confirm('Yakin ingin menghapus?')">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="bg-red-500 hover:bg-red-600 text-white px-3 py-1 rounded transition duration-200">
|
||||
Hapus
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
@if($guru->isEmpty())
|
||||
<tr>
|
||||
<td colspan="6" class="text-center text-gray-500 py-6">
|
||||
Tidak ada data guru.
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
|
@ -49,7 +49,14 @@
|
|||
|
||||
|
||||
// Guru
|
||||
Route::get('/guru', [GuruController::class, 'index'])->name('admin.guru');
|
||||
Route::controller(GuruController::class)->group(function () {
|
||||
Route::get('/guru', 'index')->name('admin.guru.index'); // halaman utama guru
|
||||
Route::get('/guru/create', 'create')->name('admin.guru.create'); // form tambah guru
|
||||
Route::post('/guru', 'store')->name('admin.guru.store'); // simpan guru baru
|
||||
Route::get('/guru/{id}/edit', 'edit')->name('admin.guru.edit'); // form edit guru
|
||||
Route::put('/guru/{id}', 'update')->name('admin.guru.update'); // simpan update guru
|
||||
Route::delete('/guru/{id}', 'destroy')->name('admin.guru.destroy'); // hapus guru
|
||||
});
|
||||
|
||||
// Kelas
|
||||
Route::resource('kelas', KelasController::class)->parameters([
|
||||
|
|
Loading…
Reference in New Issue