tampilan ruangan & kelas

This commit is contained in:
rendygaafk 2025-04-26 02:07:30 +07:00
parent d929de0690
commit 49c40fef45
6 changed files with 450 additions and 165 deletions

View File

@ -33,13 +33,6 @@ public function jurusan()
return $this->belongsTo(Jurusan::class, 'id_jurusan'); return $this->belongsTo(Jurusan::class, 'id_jurusan');
} }
/**
* Relasi ke model Announcement (pengumuman)
*/
public function announcements()
{
return $this->hasMany(Announcement::class, 'ruangan_id');
}
/** /**
* Accessor untuk nama ruangan * Accessor untuk nama ruangan

View File

@ -3,50 +3,84 @@
@section('title', 'Smart School | Tambah Jurusan') @section('title', 'Smart School | Tambah Jurusan')
@section('content') @section('content')
<div class="container mx-auto px-4 py-6"> <div class="container mx-auto px-4 py-8">
<div class="bg-white rounded-xl shadow-md overflow-hidden max-w-2xl mx-auto"> <!-- Header Section -->
<!-- Header Card --> <div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-8 gap-4">
<div class="bg-gradient-to-r from-blue-500 to-blue-600 px-6 py-4"> <div>
<h1 class="text-xl font-semibold text-white flex items-center"> <h1 class="text-3xl font-bold text-gray-800">Tambah Jurusan 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 jurusan baru ke sistem</p>
</div>
</div>
<a href="{{ route('admin.jurusan.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"> <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" /> <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> </svg>
Tambah Jurusan Baru Form Tambah Jurusan
</h1> </h2>
</div> </div>
<!-- Form Section --> <!-- Form Content -->
<div class="p-6"> <div class="p-6">
<form id="createForm" action="{{ route('admin.jurusan.store') }}" method="POST"> <form id="createForm" action="{{ route('admin.jurusan.store') }}" method="POST">
@csrf @csrf
<!-- Nama Jurusan --> <!-- Nama Jurusan -->
<div class="mb-6"> <div class="mb-6">
<label for="nama_jurusan" class="block text-sm font-medium text-gray-700 mb-2">Nama Jurusan</label> <label for="nama_jurusan" class="block text-sm font-medium text-gray-700 mb-2">Nama Jurusan <span class="text-red-500">*</span></label>
<input type="text" name="nama_jurusan" id="nama_jurusan" <input type="text" name="nama_jurusan" id="nama_jurusan"
class="w-full px-4 py-2 rounded-lg border border-gray-300 focus:border-blue-500 focus:ring focus:ring-blue-200 transition duration-300" 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_jurusan') border-red-500 @enderror"
value="{{ old('nama_jurusan') }}" value="{{ old('nama_jurusan') }}"
placeholder="Contoh: Teknik Komputer dan Jaringan" required> placeholder="Contoh: Teknik Komputer dan Jaringan" required>
@error('nama_jurusan') @error('nama_jurusan')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p> <p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<!-- Kode Jurusan -->
<div class="mb-6">
<label for="kode_jurusan" class="block text-sm font-medium text-gray-700 mb-2">Kode Jurusan</label>
<input type="text" name="kode_jurusan" id="kode_jurusan"
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('kode_jurusan') border-red-500 @enderror"
value="{{ old('kode_jurusan') }}"
placeholder="Contoh: TKJ">
@error('kode_jurusan')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror @enderror
</div> </div>
<!-- Action Buttons --> <!-- Action Buttons -->
<div class="flex justify-end space-x-3"> <div class="flex justify-end space-x-4 pt-6 border-t border-gray-200">
<a href="{{ route('admin.jurusan.index') }}" <button type="reset"
class="px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-100 transition duration-300 flex items-center"> 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-1" viewBox="0 0 20 20" fill="currentColor"> <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" /> <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> </svg>
Batal Reset
</a> </button>
<button type="button" onclick="confirmCreate()" <button type="button" onclick="confirmCreate()"
class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg transition duration-300 shadow-md hover:shadow-lg flex items-center"> 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-1" viewBox="0 0 20 20" fill="currentColor"> <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" /> <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> </svg>
Simpan Simpan Jurusan
</button> </button>
</div> </div>
</form> </form>
@ -79,13 +113,18 @@ function confirmCreate() {
confirmButtonColor: '#3085d6', confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33', cancelButtonColor: '#d33',
confirmButtonText: 'Ya, Simpan!', confirmButtonText: 'Ya, Simpan!',
cancelButtonText: 'Batal' cancelButtonText: 'Batal',
backdrop: `
rgba(0,0,0,0.7)
url("https://sweetalert2.github.io/images/nyan-cat.gif")
left top
no-repeat
`
}).then((result) => { }).then((result) => {
if (result.isConfirmed) { if (result.isConfirmed) {
// Tampilkan loading
Swal.fire({ Swal.fire({
title: 'Menyimpan...', title: 'Menyimpan...',
html: 'Mohon tunggu sebentar', html: 'Sedang menyimpan data jurusan',
allowOutsideClick: false, allowOutsideClick: false,
didOpen: () => { didOpen: () => {
Swal.showLoading(); Swal.showLoading();
@ -95,6 +134,5 @@ function confirmCreate() {
} }
}); });
} }
</script> </script>
@endsection @endsection

View File

@ -3,19 +3,41 @@
@section('title', 'Smart School | Edit Jurusan') @section('title', 'Smart School | Edit Jurusan')
@section('content') @section('content')
<div class="container mx-auto px-4 py-6"> <div class="container mx-auto px-4 py-8">
<div class="bg-white rounded-xl shadow-md overflow-hidden max-w-2xl mx-auto"> <!-- Header Section -->
<!-- Header Card --> <div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-8 gap-4">
<div class="bg-gradient-to-r from-blue-500 to-blue-600 px-6 py-4"> <div>
<h1 class="text-xl font-semibold text-white flex items-center"> <h1 class="text-3xl font-bold text-gray-800">Edit Jurusan</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">Perbarui data jurusan yang sudah ada</p>
</div>
</div>
<a href="{{ route('admin.jurusan.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"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
<path d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z" /> <path d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z" />
</svg> </svg>
Edit Data Jurusan Form Edit Jurusan
</h1> </h2>
</div> </div>
<!-- Form Section --> <!-- Form Content -->
<div class="p-6"> <div class="p-6">
<form id="editForm" action="{{ route('admin.jurusan.update', $jurusan->id) }}" method="POST"> <form id="editForm" action="{{ route('admin.jurusan.update', $jurusan->id) }}" method="POST">
@csrf @csrf
@ -23,31 +45,43 @@
<!-- Nama Jurusan --> <!-- Nama Jurusan -->
<div class="mb-6"> <div class="mb-6">
<label for="nama_jurusan" class="block text-sm font-medium text-gray-700 mb-2">Nama Jurusan</label> <label for="nama_jurusan" class="block text-sm font-medium text-gray-700 mb-2">Nama Jurusan <span class="text-red-500">*</span></label>
<input type="text" name="nama_jurusan" id="nama_jurusan" <input type="text" name="nama_jurusan" id="nama_jurusan"
class="w-full px-4 py-2 rounded-lg border border-gray-300 focus:border-blue-500 focus:ring focus:ring-blue-200 transition duration-300" 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_jurusan') border-red-500 @enderror"
value="{{ old('nama_jurusan', $jurusan->nama_jurusan) }}" value="{{ old('nama_jurusan', $jurusan->nama_jurusan) }}"
placeholder="Contoh: Teknik Komputer dan Jaringan" required> placeholder="Contoh: Teknik Komputer dan Jaringan" required>
@error('nama_jurusan') @error('nama_jurusan')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p> <p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<!-- Kode Jurusan -->
<div class="mb-6">
<label for="kode_jurusan" class="block text-sm font-medium text-gray-700 mb-2">Kode Jurusan</label>
<input type="text" name="kode_jurusan" id="kode_jurusan"
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('kode_jurusan') border-red-500 @enderror"
value="{{ old('kode_jurusan', $jurusan->kode_jurusan) }}"
placeholder="Contoh: TKJ">
@error('kode_jurusan')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror @enderror
</div> </div>
<!-- Action Buttons --> <!-- Action Buttons -->
<div class="flex justify-end space-x-3"> <div class="flex justify-end space-x-4 pt-6 border-t border-gray-200">
<a href="{{ route('admin.jurusan.index') }}" <button type="reset"
class="px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-100 transition duration-300 flex items-center"> 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-1" viewBox="0 0 20 20" fill="currentColor"> <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" /> <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> </svg>
Batal Reset
</a> </button>
<button type="button" onclick="confirmUpdate()" <button type="button" onclick="confirmUpdate()"
class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg transition duration-300 shadow-md hover:shadow-lg flex items-center"> 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-1" viewBox="0 0 20 20" fill="currentColor"> <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" /> <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> </svg>
Update Update Jurusan
</button> </button>
</div> </div>
</form> </form>
@ -62,22 +96,37 @@ class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg transition
function confirmUpdate() { function confirmUpdate() {
const form = document.getElementById('editForm'); const form = document.getElementById('editForm');
const namaJurusan = document.getElementById('nama_jurusan').value; const namaJurusan = document.getElementById('nama_jurusan').value;
const currentNama = "{{ $jurusan->nama_jurusan }}";
if (namaJurusan === currentNama) {
Swal.fire({
icon: 'info',
title: 'Tidak ada perubahan',
text: 'Anda belum melakukan perubahan pada data jurusan',
});
return;
}
Swal.fire({ Swal.fire({
title: 'Update Data Jurusan?', title: 'Update Data Jurusan?',
html: `Anda akan mengupdate jurusan menjadi:<br><strong>${namaJurusan}</strong>`, html: `Anda akan mengubah jurusan dari:<br><strong>${currentNama}</strong><br>menjadi:<br><strong>${namaJurusan}</strong>`,
icon: 'question', icon: 'question',
showCancelButton: true, showCancelButton: true,
confirmButtonColor: '#3085d6', confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33', cancelButtonColor: '#d33',
confirmButtonText: 'Ya, Update!', confirmButtonText: 'Ya, Update!',
cancelButtonText: 'Batal' cancelButtonText: 'Batal',
backdrop: `
rgba(0,0,0,0.7)
url("https://sweetalert2.github.io/images/nyan-cat.gif")
left top
no-repeat
`
}).then((result) => { }).then((result) => {
if (result.isConfirmed) { if (result.isConfirmed) {
// Tampilkan loading
Swal.fire({ Swal.fire({
title: 'Memperbarui...', title: 'Memperbarui...',
html: 'Mohon tunggu sebentar', html: 'Sedang menyimpan perubahan',
allowOutsideClick: false, allowOutsideClick: false,
didOpen: () => { didOpen: () => {
Swal.showLoading(); Swal.showLoading();
@ -87,6 +136,5 @@ function confirmUpdate() {
} }
}); });
} }
</script> </script>
@endsection @endsection

View File

@ -3,53 +3,78 @@
@section('title', 'Smart School | Manajemen Jurusan') @section('title', 'Smart School | Manajemen Jurusan')
@section('content') @section('content')
<div class="container mx-auto px-4 py-6"> <div class="container mx-auto px-4 py-8">
<!-- Header Section --> <!-- Header Section with Gradient -->
<div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-6 gap-4"> <div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-8 gap-4">
<div> <div>
<h1 class="text-2xl font-bold text-gray-800">Manajemen Jurusan</h1> <h1 class="text-3xl font-bold text-gray-800">Manajemen Jurusan</h1>
<p class="text-sm text-gray-600">Kelola data jurusan sekolah</p> <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">Kelola data jurusan sekolah dengan mudah</p>
</div>
</div> </div>
<a href="{{ route('admin.jurusan.create') }}" <a href="{{ route('admin.jurusan.create') }}"
class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center transition duration-300 shadow-md hover:shadow-lg"> 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-1" viewBox="0 0 20 20" fill="currentColor"> <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" /> <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> </svg>
Tambah Jurusan Tambah Jurusan Baru
</a> </a>
</div> </div>
<!-- Stats Card --> <!-- Stats Cards -->
<div class="grid grid-cols-1 gap-4 mb-6"> <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
<div class="bg-white rounded-xl shadow-md p-5 border-l-4 border-blue-500"> <!-- Total Jurusan -->
<div class="bg-white rounded-xl shadow-lg p-6 border-l-4 border-blue-500 hover:shadow-md transition duration-300">
<div class="flex items-center"> <div class="flex items-center">
<div class="p-3 rounded-full bg-blue-100"> <div class="p-3 rounded-full bg-blue-100">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10" />
</svg> </svg>
</div> </div>
<div class="ml-4"> <div class="ml-4">
<h3 class="text-sm font-medium text-gray-500">Total Jurusan</h3> <h3 class="text-sm font-medium text-gray-500">Total Jurusan</h3>
<p class="text-lg font-semibold text-gray-700">{{ $jurusan->count() }}</p> <p class="text-2xl font-bold text-gray-700">{{ $jurusan->count() }}</p>
</div>
</div>
</div>
<!-- Jurusan Aktif -->
<div class="bg-white rounded-xl shadow-lg p-6 border-l-4 border-green-500 hover:shadow-md transition duration-300">
<div class="flex items-center">
<div class="p-3 rounded-full bg-green-100">
<svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8 text-green-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</div>
<div class="ml-4">
<h3 class="text-sm font-medium text-gray-500">Jurusan Aktif</h3>
<p class="text-2xl font-bold text-gray-700">{{ $jurusan->count() }}</p>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- Table Section --> <!-- Main Content Card -->
<div class="bg-white rounded-xl shadow-md overflow-hidden"> <div class="bg-white rounded-xl shadow-lg overflow-hidden">
<!-- Filter and Search --> <!-- Card Header with Filter -->
<div class="px-6 py-4 border-b border-gray-200"> <div class="px-6 py-4 border-b border-gray-200 bg-gradient-to-r from-gray-50 to-white">
<div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-4"> <div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-4">
<div>
<h2 class="text-lg font-semibold text-gray-800">Daftar Jurusan</h2>
<p class="text-sm text-gray-500">Manajemen semua jurusan yang terdaftar</p>
</div>
<form action="{{ route('admin.jurusan.index') }}" method="GET" class="flex flex-wrap items-center gap-4 w-full md:w-auto"> <form action="{{ route('admin.jurusan.index') }}" method="GET" class="flex flex-wrap items-center gap-4 w-full md:w-auto">
<!-- Search Box --> <!-- Search Box -->
<div class="w-full md:w-auto flex-grow"> <div class="w-full md:w-auto flex-grow">
<label for="search" class="block text-sm font-medium text-gray-700 mb-1">Cari Jurusan</label>
<div class="relative"> <div class="relative">
<input type="text" id="search" name="search" placeholder="Cari nama jurusan..." <input type="text" id="search" name="search" placeholder="Cari nama jurusan..."
value="{{ request('search') }}" value="{{ request('search') }}"
class="block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 pl-10"> class="block w-full md:w-64 rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 pl-10 pr-4 py-2">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none"> <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-400" viewBox="0 0 20 20" fill="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-400" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd" /> <path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd" />
@ -60,7 +85,7 @@ class="block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 f
@if(request('search')) @if(request('search'))
<div class="flex items-end"> <div class="flex items-end">
<a href="{{ route('admin.jurusan.index') }}" class="text-sm text-blue-600 hover:underline flex items-center mt-1"> <a href="{{ route('admin.jurusan.index') }}" class="text-sm text-blue-600 hover:text-blue-800 hover:underline flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-1" viewBox="0 0 20 20" fill="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-1" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z" clip-rule="evenodd" /> <path fill-rule="evenodd" d="M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z" clip-rule="evenodd" />
</svg> </svg>
@ -77,33 +102,52 @@ class="block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 f
<table class="min-w-full divide-y divide-gray-200"> <table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50"> <thead class="bg-gray-50">
<tr> <tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">No</th> <th scope="col" class="px-6 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">No</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nama Jurusan</th> <th scope="col" class="px-6 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">Nama Jurusan</th>
<th scope="col" class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Aksi</th> <!-- <th scope="col" class="px-6 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">Jumlah Ruangan</th> -->
<th scope="col" class="px-6 py-3 text-right text-xs font-semibold text-gray-600 uppercase tracking-wider">Aksi</th>
</tr> </tr>
</thead> </thead>
<tbody class="bg-white divide-y divide-gray-200"> <tbody class="bg-white divide-y divide-gray-200">
@forelse($jurusan as $index => $item) @forelse($jurusan as $index => $item)
<tr class="hover:bg-gray-50 transition duration-150"> <tr class="hover:bg-gray-50 transition duration-150 ease-in-out">
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"> <td class="px-6 py-4 whitespace-nowrap">
{{ $index + 1 }} <div class="text-sm font-medium text-gray-900">{{ $index + 1 }}</div>
</td> </td>
<td class="px-6 py-4 whitespace-nowrap"> <td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm font-medium text-gray-900">{{ $item->nama_jurusan }}</div> <div class="flex items-center">
<div class="flex-shrink-0 h-10 w-10 bg-blue-100 rounded-lg flex items-center justify-center mr-3">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10" />
</svg>
</div>
<div>
<div class="text-sm font-semibold text-gray-900">{{ $item->nama_jurusan }}</div>
<!-- <div class="text-xs text-gray-500">Kode: {{ $item->kode_jurusan ?? '-' }}</div> -->
</div>
</div>
</td> </td>
<!-- <td class="px-6 py-4 whitespace-nowrap">
<span class="px-3 py-1 inline-flex text-xs leading-5 font-semibold rounded-full bg-blue-100 text-blue-800">
{{ $item->ruangan_count ?? 0 }} Ruangan
</span>
</td> -->
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium"> <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<div class="flex justify-end space-x-2"> <div class="flex justify-end space-x-3">
<a href="{{ route('admin.jurusan.edit', $item->id) }}" <a href="{{ route('admin.jurusan.edit', $item->id) }}"
class="text-yellow-600 hover:text-yellow-900 inline-flex items-center"> class="text-blue-600 hover:text-blue-900 inline-flex items-center transition duration-150 ease-in-out transform hover:scale-110"
title="Edit">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z" /> <path d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z" />
</svg> </svg>
</a> </a>
<form action="{{ route('admin.jurusan.destroy', $item->id) }}" method="POST" class="inline"> <form action="{{ route('admin.jurusan.destroy', $item->id) }}" method="POST" class="inline">
@csrf @csrf
@method('DELETE') @method('DELETE')
<button type="button" onclick="confirmDelete('{{ $item->nama_jurusan }}', this.form)" <button type="button" onclick="confirmDelete('{{ $item->nama_jurusan }}', this.form)"
class="text-red-600 hover:text-red-900 inline-flex items-center"> class="text-red-600 hover:text-red-900 inline-flex items-center transition duration-150 ease-in-out transform hover:scale-110"
title="Hapus">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd" /> <path fill-rule="evenodd" d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd" />
</svg> </svg>
@ -114,7 +158,15 @@ class="text-red-600 hover:text-red-900 inline-flex items-center">
</tr> </tr>
@empty @empty
<tr> <tr>
<td colspan="3" class="px-6 py-4 text-center text-gray-500">Belum ada data jurusan</td> <td colspan="4" class="px-6 py-8 text-center">
<div class="flex flex-col items-center justify-center text-gray-400">
<svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12 mb-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M9.172 16.172a4 4 0 015.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<h3 class="text-lg font-medium">Belum ada data jurusan</h3>
<p class="text-sm mt-1">Silakan tambah jurusan baru menggunakan tombol di atas</p>
</div>
</td>
</tr> </tr>
@endforelse @endforelse
</tbody> </tbody>
@ -123,8 +175,8 @@ class="text-red-600 hover:text-red-900 inline-flex items-center">
<!-- Pagination --> <!-- Pagination -->
@if($jurusan->hasPages()) @if($jurusan->hasPages())
<div class="px-6 py-4 border-t border-gray-200"> <div class="px-6 py-4 border-t border-gray-200 bg-gray-50">
{{ $jurusan->links() }} {{ $jurusan->links('vendor.pagination.tailwind') }}
</div> </div>
@endif @endif
</div> </div>
@ -136,17 +188,31 @@ class="text-red-600 hover:text-red-900 inline-flex items-center">
<script> <script>
function confirmDelete(name, form) { function confirmDelete(name, form) {
Swal.fire({ Swal.fire({
title: 'Hapus Jurusan?', title: 'Konfirmasi Penghapusan',
html: `Anda akan menghapus jurusan <strong>${name}</strong>`, html: `Anda yakin ingin menghapus jurusan <strong>${name}</strong>?`,
icon: 'warning', icon: 'warning',
showCancelButton: true, showCancelButton: true,
confirmButtonColor: '#3085d6', confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33', cancelButtonColor: '#d33',
confirmButtonText: 'Ya, Hapus!', confirmButtonText: 'Ya, Hapus!',
cancelButtonText: 'Batal' cancelButtonText: 'Batal',
backdrop: `
rgba(0,0,0,0.7)
url("https://sweetalert2.github.io/images/nyan-cat.gif")
left top
no-repeat
`
}).then((result) => { }).then((result) => {
if (result.isConfirmed) { if (result.isConfirmed) {
form.submit(); Swal.fire({
title: 'Dihapus!',
text: 'Jurusan berhasil dihapus.',
icon: 'success',
timer: 1500,
showConfirmButton: false
}).then(() => {
form.submit();
});
} }
}); });
} }

View File

@ -3,32 +3,81 @@
@section('title', 'Smart School | Tambah Kelas') @section('title', 'Smart School | Tambah Kelas')
@section('content') @section('content')
<div class="container mx-auto px-4 py-6"> <div class="container mx-auto px-4 py-8">
<div class="bg-white rounded-xl shadow-md overflow-hidden max-w-2xl mx-auto"> <!-- Header Section -->
<!-- Header Card --> <div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-8 gap-4">
<div class="bg-gradient-to-r from-blue-500 to-blue-600 px-6 py-4"> <div>
<h1 class="text-xl font-semibold text-white flex items-center"> <h1 class="text-3xl font-bold text-gray-800">Tambah Kelas 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 kelas baru ke sistem</p>
</div>
</div>
<a href="{{ route('admin.kelas.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"> <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" /> <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> </svg>
Tambah Kelas Baru Form Tambah Kelas
</h1> </h2>
</div> </div>
<!-- Form Section --> <!-- Form Content -->
<div class="p-6"> <div class="p-6">
<form id="createForm" action="{{ route('admin.kelas.store') }}" method="POST"> <form id="createForm" action="{{ route('admin.kelas.store') }}" method="POST">
@csrf @csrf
<!-- Nama Kelas --> <!-- Nama Kelas -->
<div class="mb-6"> <div class="mb-6">
<label for="nama_kelas" class="block text-sm font-medium text-gray-700 mb-2">Nama Kelas</label> <label for="nama_kelas" class="block text-sm font-medium text-gray-700 mb-2">Nama Kelas <span class="text-red-500">*</span></label>
<input type="text" name="nama_kelas" id="nama_kelas" <input type="text" name="nama_kelas" id="nama_kelas"
class="w-full px-4 py-2 rounded-lg border border-gray-300 focus:border-blue-500 focus:ring focus:ring-blue-200 transition duration-300" 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_kelas') border-red-500 @enderror"
value="{{ old('nama_kelas') }}" value="{{ old('nama_kelas') }}"
placeholder="Contoh: X IPA 1" required> placeholder="Contoh: X IPA 1" required>
@error('nama_kelas') @error('nama_kelas')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p> <p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<!-- Kode Kelas -->
<div class="mb-6">
<label for="kode_kelas" class="block text-sm font-medium text-gray-700 mb-2">Kode Kelas</label>
<input type="text" name="kode_kelas" id="kode_kelas"
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('kode_kelas') border-red-500 @enderror"
value="{{ old('kode_kelas') }}"
placeholder="Contoh: XIPA1">
@error('kode_kelas')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<!-- Tingkat -->
<div class="mb-6">
<label for="tingkat" class="block text-sm font-medium text-gray-700 mb-2">Tingkat <span class="text-red-500">*</span></label>
<select name="tingkat" id="tingkat"
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('tingkat') border-red-500 @enderror" required>
<option value="">-- Pilih Tingkat --</option>
<option value="X" {{ old('tingkat') == 'X' ? 'selected' : '' }}>X</option>
<option value="XI" {{ old('tingkat') == 'XI' ? 'selected' : '' }}>XI</option>
<option value="XII" {{ old('tingkat') == 'XII' ? 'selected' : '' }}>XII</option>
</select>
@error('tingkat')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror @enderror
</div> </div>
@ -36,7 +85,7 @@ class="w-full px-4 py-2 rounded-lg border border-gray-300 focus:border-blue-500
<div class="mb-6"> <div class="mb-6">
<label for="id_jurusan" class="block text-sm font-medium text-gray-700 mb-2">Jurusan</label> <label for="id_jurusan" class="block text-sm font-medium text-gray-700 mb-2">Jurusan</label>
<select name="id_jurusan" id="id_jurusan" <select name="id_jurusan" id="id_jurusan"
class="w-full px-4 py-2 rounded-lg border border-gray-300 focus:border-blue-500 focus:ring focus:ring-blue-200 transition duration-300"> 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('id_jurusan') border-red-500 @enderror">
<option value="">-- Pilih Jurusan --</option> <option value="">-- Pilih Jurusan --</option>
@foreach ($jurusan as $item) @foreach ($jurusan as $item)
<option value="{{ $item->id }}" {{ old('id_jurusan') == $item->id ? 'selected' : '' }}> <option value="{{ $item->id }}" {{ old('id_jurusan') == $item->id ? 'selected' : '' }}>
@ -45,25 +94,25 @@ class="w-full px-4 py-2 rounded-lg border border-gray-300 focus:border-blue-500
@endforeach @endforeach
</select> </select>
@error('id_jurusan') @error('id_jurusan')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p> <p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror @enderror
</div> </div>
<!-- Action Buttons --> <!-- Action Buttons -->
<div class="flex justify-end space-x-3"> <div class="flex justify-end space-x-4 pt-6 border-t border-gray-200">
<a href="{{ route('admin.kelas.index') }}" <button type="reset"
class="px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-100 transition duration-300 flex items-center"> 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-1" viewBox="0 0 20 20" fill="currentColor"> <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" /> <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> </svg>
Batal Reset
</a> </button>
<button type="button" onclick="confirmCreate()" <button type="button" onclick="confirmCreate()"
class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg transition duration-300 shadow-md hover:shadow-lg flex items-center"> 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-1" viewBox="0 0 20 20" fill="currentColor"> <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" /> <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> </svg>
Simpan Simpan Kelas
</button> </button>
</div> </div>
</form> </form>
@ -78,6 +127,7 @@ class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg transition
function confirmCreate() { function confirmCreate() {
const form = document.getElementById('createForm'); const form = document.getElementById('createForm');
const namaKelas = document.getElementById('nama_kelas').value; const namaKelas = document.getElementById('nama_kelas').value;
const tingkat = document.getElementById('tingkat').value;
const jurusan = document.getElementById('id_jurusan').options[document.getElementById('id_jurusan').selectedIndex].text; const jurusan = document.getElementById('id_jurusan').options[document.getElementById('id_jurusan').selectedIndex].text;
if (!namaKelas) { if (!namaKelas) {
@ -89,21 +139,38 @@ function confirmCreate() {
return; return;
} }
if (!tingkat) {
Swal.fire({
icon: 'error',
title: 'Oops...',
text: 'Tingkat kelas harus dipilih!',
});
return;
}
Swal.fire({ Swal.fire({
title: 'Tambah Kelas Baru?', title: 'Tambah Kelas Baru?',
html: `Anda akan menambahkan kelas:<br><strong>${namaKelas}</strong>`, html: `Anda akan menambahkan kelas:<br>
<strong>${namaKelas}</strong><br>
Tingkat: <strong>${tingkat}</strong><br>
Jurusan: <strong>${jurusan || '-'}</strong>`,
icon: 'question', icon: 'question',
showCancelButton: true, showCancelButton: true,
confirmButtonColor: '#3085d6', confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33', cancelButtonColor: '#d33',
confirmButtonText: 'Ya, Simpan!', confirmButtonText: 'Ya, Simpan!',
cancelButtonText: 'Batal' cancelButtonText: 'Batal',
backdrop: `
rgba(0,0,0,0.7)
url("https://sweetalert2.github.io/images/nyan-cat.gif")
left top
no-repeat
`
}).then((result) => { }).then((result) => {
if (result.isConfirmed) { if (result.isConfirmed) {
// Tampilkan loading
Swal.fire({ Swal.fire({
title: 'Menyimpan...', title: 'Menyimpan...',
html: 'Mohon tunggu sebentar', html: 'Sedang menyimpan data kelas',
allowOutsideClick: false, allowOutsideClick: false,
didOpen: () => { didOpen: () => {
Swal.showLoading(); Swal.showLoading();
@ -113,6 +180,5 @@ function confirmCreate() {
} }
}); });
} }
</script> </script>
@endsection @endsection

View File

@ -3,29 +3,35 @@
@section('title', 'Smart School | Manajemen Kelas') @section('title', 'Smart School | Manajemen Kelas')
@section('content') @section('content')
<div class="container mx-auto px-4 py-6"> <div class="container mx-auto px-4 py-8">
<!-- Header Section --> <!-- Header Section with Gradient -->
<div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-6 gap-4"> <div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-8 gap-4">
<div> <div>
<h1 class="text-2xl font-bold text-gray-800">Manajemen Kelas</h1> <h1 class="text-3xl font-bold text-gray-800">Manajemen Kelas</h1>
<p class="text-sm text-gray-600">Kelola data kelas dan jurusan</p> <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">Kelola data kelas dan jurusan dengan mudah</p>
</div>
</div> </div>
<a href="{{ route('admin.kelas.create') }}" <a href="{{ route('admin.kelas.create') }}"
class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center transition duration-300 shadow-md hover:shadow-lg"> 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-1" viewBox="0 0 20 20" fill="currentColor"> <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" /> <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> </svg>
Tambah Kelas Tambah Kelas Baru
</a> </a>
</div> </div>
<!-- Stats Card --> <!-- Stats Cards -->
<div class="grid grid-cols-1 gap-4 mb-6"> <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
<div class="bg-white rounded-xl shadow-md p-5 border-l-4 border-blue-500"> <!-- Total Kelas -->
<div class="bg-white rounded-xl shadow-lg p-6 border-l-4 border-blue-500 hover:shadow-md transition duration-300">
<div class="flex items-center"> <div class="flex items-center">
<div class="p-3 rounded-full bg-blue-100"> <div class="p-3 rounded-full bg-blue-100">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path d="M12 14l9-5-9-5-9 5 9 5z" /> <path d="M12 14l9-5-9-5-9 5 9 5z" />
<path d="M12 14l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14z" /> <path d="M12 14l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 14l9-5-9-5-9 5 9 5zm0 0l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14zm-4 6v-7.5l4-2.222" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 14l9-5-9-5-9 5 9 5zm0 0l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14zm-4 6v-7.5l4-2.222" />
@ -33,25 +39,59 @@ class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-
</div> </div>
<div class="ml-4"> <div class="ml-4">
<h3 class="text-sm font-medium text-gray-500">Total Kelas</h3> <h3 class="text-sm font-medium text-gray-500">Total Kelas</h3>
<p class="text-lg font-semibold text-gray-700">{{ $kelas->count() }}</p> <p class="text-2xl font-bold text-gray-700">{{ $kelas->count() }}</p>
</div>
</div>
</div>
<!-- Kelas Aktif -->
<div class="bg-white rounded-xl shadow-lg p-6 border-l-4 border-green-500 hover:shadow-md transition duration-300">
<div class="flex items-center">
<div class="p-3 rounded-full bg-green-100">
<svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8 text-green-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</div>
<div class="ml-4">
<h3 class="text-sm font-medium text-gray-500">Kelas Aktif</h3>
<p class="text-2xl font-bold text-gray-700">{{ $kelas->count() }}</p>
</div>
</div>
</div>
<!-- Kelas per Jurusan -->
<div class="bg-white rounded-xl shadow-lg p-6 border-l-4 border-purple-500 hover:shadow-md transition duration-300">
<div class="flex items-center">
<div class="p-3 rounded-full bg-purple-100">
<svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8 text-purple-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10" />
</svg>
</div>
<div class="ml-4">
<h3 class="text-sm font-medium text-gray-500">Jurusan Terdaftar</h3>
<p class="text-2xl font-bold text-gray-700">{{ $kelas->unique('jurusan_id')->count() }}</p>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- Table Section --> <!-- Main Content Card -->
<div class="bg-white rounded-xl shadow-md overflow-hidden"> <div class="bg-white rounded-xl shadow-lg overflow-hidden">
<!-- Filter and Search --> <!-- Card Header with Filter -->
<div class="px-6 py-4 border-b border-gray-200"> <div class="px-6 py-4 border-b border-gray-200 bg-gradient-to-r from-gray-50 to-white">
<div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-4"> <div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-4">
<div>
<h2 class="text-lg font-semibold text-gray-800">Daftar Kelas</h2>
<p class="text-sm text-gray-500">Manajemen semua kelas yang terdaftar</p>
</div>
<form action="{{ route('admin.kelas.index') }}" method="GET" class="flex flex-wrap items-center gap-4 w-full md:w-auto"> <form action="{{ route('admin.kelas.index') }}" method="GET" class="flex flex-wrap items-center gap-4 w-full md:w-auto">
<!-- Search Box --> <!-- Search Box -->
<div class="w-full md:w-auto flex-grow"> <div class="w-full md:w-auto flex-grow">
<label for="search" class="block text-sm font-medium text-gray-700 mb-1">Cari Kelas</label>
<div class="relative"> <div class="relative">
<input type="text" id="search" name="search" placeholder="Cari nama kelas..." <input type="text" id="search" name="search" placeholder="Cari nama kelas..."
value="{{ request('search') }}" value="{{ request('search') }}"
class="block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 pl-10"> class="block w-full md:w-64 rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 pl-10 pr-4 py-2">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none"> <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-400" viewBox="0 0 20 20" fill="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-400" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd" /> <path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd" />
@ -62,7 +102,7 @@ class="block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 f
@if(request('search')) @if(request('search'))
<div class="flex items-end"> <div class="flex items-end">
<a href="{{ route('admin.kelas.index') }}" class="text-sm text-blue-600 hover:underline flex items-center mt-1"> <a href="{{ route('admin.kelas.index') }}" class="text-sm text-blue-600 hover:text-blue-800 hover:underline flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-1" viewBox="0 0 20 20" fill="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-1" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z" clip-rule="evenodd" /> <path fill-rule="evenodd" d="M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z" clip-rule="evenodd" />
</svg> </svg>
@ -79,45 +119,58 @@ class="block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 f
<table class="min-w-full divide-y divide-gray-200"> <table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50"> <thead class="bg-gray-50">
<tr> <tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">No</th> <th scope="col" class="px-6 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">No</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nama Kelas</th> <th scope="col" class="px-6 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">Nama Kelas</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Jurusan</th> <th scope="col" class="px-6 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">Jurusan</th>
<th scope="col" class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Aksi</th> <th scope="col" class="px-6 py-3 text-right text-xs font-semibold text-gray-600 uppercase tracking-wider">Aksi</th>
</tr> </tr>
</thead> </thead>
<tbody class="bg-white divide-y divide-gray-200"> <tbody class="bg-white divide-y divide-gray-200">
@forelse($kelas as $index => $item) @forelse($kelas as $index => $item)
<tr class="hover:bg-gray-50 transition duration-150"> <tr class="hover:bg-gray-50 transition duration-150 ease-in-out">
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"> <td class="px-6 py-4 whitespace-nowrap">
{{ $index + 1 }} <div class="text-sm font-medium text-gray-900">{{ $index + 1 }}</div>
</td> </td>
<td class="px-6 py-4 whitespace-nowrap"> <td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm font-medium text-gray-900">{{ $item->nama_kelas }}</div> <div class="flex items-center">
<div class="flex-shrink-0 h-10 w-10 bg-blue-100 rounded-lg flex items-center justify-center mr-3">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path d="M12 14l9-5-9-5-9 5 9 5z" />
<path d="M12 14l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14z" />
</svg>
</div>
<div>
<div class="text-sm font-semibold text-gray-900">{{ $item->nama_kelas }}</div>
</div>
</div>
</td> </td>
<td class="px-6 py-4 whitespace-nowrap"> <td class="px-6 py-4 whitespace-nowrap">
@if($item->jurusan) @if($item->jurusan)
<span class="px-2 py-1 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800"> <span class="px-3 py-1 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
{{ $item->jurusan->nama_jurusan }} {{ $item->jurusan->nama_jurusan }}
</span> </span>
@else @else
<span class="px-2 py-1 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800"> <span class="px-3 py-1 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">
- -
</span> </span>
@endif @endif
</td> </td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium"> <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<div class="flex justify-end space-x-2"> <div class="flex justify-end space-x-3">
<a href="{{ route('admin.kelas.edit', $item->id) }}" <a href="{{ route('admin.kelas.edit', $item->id) }}"
class="text-yellow-600 hover:text-yellow-900 inline-flex items-center"> class="text-blue-600 hover:text-blue-900 inline-flex items-center transition duration-150 ease-in-out transform hover:scale-110"
title="Edit">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z" /> <path d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z" />
</svg> </svg>
</a> </a>
<form action="{{ route('admin.kelas.destroy', $item->id) }}" method="POST" class="inline"> <form action="{{ route('admin.kelas.destroy', $item->id) }}" method="POST" class="inline">
@csrf @csrf
@method('DELETE') @method('DELETE')
<button type="button" onclick="confirmDelete('{{ $item->nama_kelas }}', this.form)" <button type="button" onclick="confirmDelete('{{ $item->nama_kelas }}', this.form)"
class="text-red-600 hover:text-red-900 inline-flex items-center"> class="text-red-600 hover:text-red-900 inline-flex items-center transition duration-150 ease-in-out transform hover:scale-110"
title="Hapus">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd" /> <path fill-rule="evenodd" d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd" />
</svg> </svg>
@ -128,7 +181,15 @@ class="text-red-600 hover:text-red-900 inline-flex items-center">
</tr> </tr>
@empty @empty
<tr> <tr>
<td colspan="4" class="px-6 py-4 text-center text-gray-500">Belum ada data kelas</td> <td colspan="5" class="px-6 py-8 text-center">
<div class="flex flex-col items-center justify-center text-gray-400">
<svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12 mb-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M9.172 16.172a4 4 0 015.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<h3 class="text-lg font-medium">Belum ada data kelas</h3>
<p class="text-sm mt-1">Silakan tambah kelas baru menggunakan tombol di atas</p>
</div>
</td>
</tr> </tr>
@endforelse @endforelse
</tbody> </tbody>
@ -137,8 +198,8 @@ class="text-red-600 hover:text-red-900 inline-flex items-center">
<!-- Pagination --> <!-- Pagination -->
@if($kelas->hasPages()) @if($kelas->hasPages())
<div class="px-6 py-4 border-t border-gray-200"> <div class="px-6 py-4 border-t border-gray-200 bg-gray-50">
{{ $kelas->links() }} {{ $kelas->links('vendor.pagination.tailwind') }}
</div> </div>
@endif @endif
</div> </div>
@ -150,20 +211,33 @@ class="text-red-600 hover:text-red-900 inline-flex items-center">
<script> <script>
function confirmDelete(name, form) { function confirmDelete(name, form) {
Swal.fire({ Swal.fire({
title: 'Hapus Kelas?', title: 'Konfirmasi Penghapusan',
html: `Anda akan menghapus kelas <strong>${name}</strong>`, html: `Anda yakin ingin menghapus kelas <strong>${name}</strong>?`,
icon: 'warning', icon: 'warning',
showCancelButton: true, showCancelButton: true,
confirmButtonColor: '#3085d6', confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33', cancelButtonColor: '#d33',
confirmButtonText: 'Ya, Hapus!', confirmButtonText: 'Ya, Hapus!',
cancelButtonText: 'Batal' cancelButtonText: 'Batal',
backdrop: `
rgba(0,0,0,0.7)
url("https://sweetalert2.github.io/images/nyan-cat.gif")
left top
no-repeat
`
}).then((result) => { }).then((result) => {
if (result.isConfirmed) { if (result.isConfirmed) {
form.submit(); Swal.fire({
title: 'Dihapus!',
text: 'Kelas berhasil dihapus.',
icon: 'success',
timer: 1500,
showConfirmButton: false
}).then(() => {
form.submit();
});
} }
}); });
} }
</script> </script>
@endsection @endsection