Menambahkan routing, controllers, dan views untuk data siswa
This commit is contained in:
parent
4284cc1d44
commit
dcbb5a11b6
|
|
@ -0,0 +1,11 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>About Page</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Ini Halaman About</h1>
|
||||||
|
<p>Selamat datang di halaman tentang saya!</p>
|
||||||
|
<p>Syifa Maulidya Ratih</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="id">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Tambahkan Data Siswa</title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-family: 'Poppins', sans-serif;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
background: linear-gradient(135deg, #74ebd5, #ACB6E5);
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
width: 90%;
|
||||||
|
max-width: 600px;
|
||||||
|
background: #ffffff;
|
||||||
|
padding: 40px;
|
||||||
|
border-radius: 20px;
|
||||||
|
box-shadow: 0 8px 25px rgba(0,0,0,0.15);
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
color: #2c3e50;
|
||||||
|
}
|
||||||
|
label {
|
||||||
|
font-weight: 600;
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
color: #34495e;
|
||||||
|
}
|
||||||
|
input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 12px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
font-size: 16px;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
input:focus {
|
||||||
|
outline: none;
|
||||||
|
border: 1px solid #3498db;
|
||||||
|
box-shadow: 0 0 8px rgba(52,152,219,0.5);
|
||||||
|
}
|
||||||
|
.button {
|
||||||
|
width: 100%;
|
||||||
|
padding: 14px;
|
||||||
|
background: #3498db;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 50px;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 16px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.3s;
|
||||||
|
}
|
||||||
|
.button:hover {
|
||||||
|
background: #2980b9;
|
||||||
|
}
|
||||||
|
.alert {
|
||||||
|
background: #f8d7da;
|
||||||
|
color: #721c24;
|
||||||
|
padding: 15px;
|
||||||
|
border-radius: 10px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
border-left: 5px solid #f5c6cb;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h1>Tambahkan Data Siswa</h1>
|
||||||
|
|
||||||
|
@if($errors->any())
|
||||||
|
<div class="alert">
|
||||||
|
@foreach($errors->all() as $error)
|
||||||
|
<p>{{ $error }}</p>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<form action="{{ route('siswa.store') }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
<label>Nama:</label>
|
||||||
|
<input type="text" name="nama" required>
|
||||||
|
|
||||||
|
<label>Kelas:</label>
|
||||||
|
<input type="text" name="kelas" required>
|
||||||
|
|
||||||
|
<label>Umur:</label>
|
||||||
|
<input type="number" name="umur" required>
|
||||||
|
|
||||||
|
<label>Absen:</label>
|
||||||
|
<input type="number" name="absen" required>
|
||||||
|
|
||||||
|
<button type="submit" class="button">Simpan Data</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,97 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="id">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Edit Data Siswa</title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-family: 'Poppins', sans-serif;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
background: linear-gradient(135deg, #74ebd5, #ACB6E5);
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
width: 90%;
|
||||||
|
max-width: 600px;
|
||||||
|
background: #ffffff;
|
||||||
|
padding: 40px;
|
||||||
|
border-radius: 20px;
|
||||||
|
box-shadow: 0 8px 25px rgba(0,0,0,0.15);
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
color: #2c3e50;
|
||||||
|
}
|
||||||
|
label {
|
||||||
|
font-weight: 600;
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
color: #34495e;
|
||||||
|
}
|
||||||
|
input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 12px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
font-size: 16px;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
input:focus {
|
||||||
|
outline: none;
|
||||||
|
border: 1px solid #3498db;
|
||||||
|
box-shadow: 0 0 8px rgba(52,152,219,0.5);
|
||||||
|
}
|
||||||
|
.button {
|
||||||
|
width: 100%;
|
||||||
|
padding: 14px;
|
||||||
|
background: #3498db;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 50px;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 16px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.3s;
|
||||||
|
}
|
||||||
|
.button:hover {
|
||||||
|
background: #2980b9;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h1>Edit Data Siswa</h1>
|
||||||
|
|
||||||
|
<form action="{{ route('siswa.update', $id) }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
|
||||||
|
<label>Nama:</label>
|
||||||
|
<input type="text" name="nama" value="{{ $siswa['nama'] }}" required>
|
||||||
|
|
||||||
|
<label>Kelas:</label>
|
||||||
|
<input type="text" name="kelas" value="{{ $siswa['kelas'] }}" required>
|
||||||
|
|
||||||
|
<label>Umur:</label>
|
||||||
|
<input type="number" name="umur" value="{{ $siswa['umur'] }}" required>
|
||||||
|
|
||||||
|
<label>Absen:</label>
|
||||||
|
<input type="number" name="absen" value="{{ $siswa['absen'] }}" required>
|
||||||
|
|
||||||
|
<button type="submit" class="button">Simpan Perubahan</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,129 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="id">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Data Siswa</title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-family: 'Poppins', sans-serif;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
background: linear-gradient(135deg, #74ebd5, #ACB6E5);
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
width: 90%;
|
||||||
|
max-width: 900px;
|
||||||
|
background: #ffffff;
|
||||||
|
padding: 40px;
|
||||||
|
border-radius: 20px;
|
||||||
|
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
color: #2c3e50;
|
||||||
|
}
|
||||||
|
.button, .button-edit {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 12px 25px;
|
||||||
|
margin-top: 20px;
|
||||||
|
color: #ffffff;
|
||||||
|
background: #3498db;
|
||||||
|
text-decoration: none;
|
||||||
|
border-radius: 50px;
|
||||||
|
font-weight: 600;
|
||||||
|
transition: background 0.3s ease;
|
||||||
|
}
|
||||||
|
.button:hover, .button-edit:hover {
|
||||||
|
background: #2980b9;
|
||||||
|
}
|
||||||
|
.alert {
|
||||||
|
padding: 15px;
|
||||||
|
background-color: #d1f2eb;
|
||||||
|
color: #117864;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
border-left: 6px solid #1abc9c;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin-top: 20px;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 15px;
|
||||||
|
}
|
||||||
|
thead {
|
||||||
|
background-color: #3498db;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
th, td {
|
||||||
|
padding: 15px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 16px;
|
||||||
|
border-bottom: 1px solid #e1e1e1;
|
||||||
|
}
|
||||||
|
tbody tr:nth-child(even) {
|
||||||
|
background-color: #f4f9fd;
|
||||||
|
}
|
||||||
|
tbody tr:hover {
|
||||||
|
background-color: #eaf6ff;
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 20px;
|
||||||
|
font-size: 18px;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h1>Data Siswa</h1>
|
||||||
|
|
||||||
|
@if(session('success'))
|
||||||
|
<div class="alert">{{ session('success') }}</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if(count($siswas) > 0)
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>No</th>
|
||||||
|
<th>Nama</th>
|
||||||
|
<th>Kelas</th>
|
||||||
|
<th>Umur</th>
|
||||||
|
<th>Absen</th>
|
||||||
|
<th>Aksi</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach($siswas as $index => $siswa)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $index + 1 }}</td>
|
||||||
|
<td>{{ $siswa['nama'] }}</td>
|
||||||
|
<td>{{ $siswa['kelas'] }}</td>
|
||||||
|
<td>{{ $siswa['umur'] }}</td>
|
||||||
|
<td>{{ $siswa['absen'] }}</td>
|
||||||
|
<td>
|
||||||
|
<a href="{{ route('siswa.edit', $index) }}" class="button-edit">Edit</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
@else
|
||||||
|
<p>Belum ada data siswa, silahkan tambahkan data.</p>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<a href="{{ route('siswa.create') }}" class="button">+ Tambah Data Siswa</a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\SiswaController;
|
||||||
|
|
||||||
|
Route::get('/', function () {
|
||||||
|
return view('welcome');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::get('/about', function () {
|
||||||
|
return view('about');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::get('/datasiswa', [SiswaController::class, 'index'])->name('siswa.index');
|
||||||
|
Route::get('/siswa/create', [SiswaController::class, 'create'])->name('siswa.create');
|
||||||
|
Route::post('/siswa', [SiswaController::class, 'store'])->name('siswa.store');
|
||||||
|
|
||||||
|
Route::get('/siswa/{id}/edit', [SiswaController::class, 'edit'])->name('siswa.edit');
|
||||||
|
Route::put('/siswa/{id}', [SiswaController::class, 'update'])->name('siswa.update');
|
||||||
Loading…
Reference in New Issue