tugas akhir

This commit is contained in:
Arlinlin 2024-06-28 14:02:38 +07:00
parent c3670d77af
commit 115c2e318f
110 changed files with 16078 additions and 0 deletions

18
.editorconfig Normal file
View File

@ -0,0 +1,18 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
[docker-compose.yml]
indent_size = 4

11
.gitattributes vendored Normal file
View File

@ -0,0 +1,11 @@
* text=auto eol=lf
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore

19
.gitignore vendored Normal file
View File

@ -0,0 +1,19 @@
/.phpunit.cache
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode

View File

@ -0,0 +1,62 @@
<?php
namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class AuthController extends Controller
{
public function login(Request $request)
{
if ($request->isMethod('POST')) {
$credentials = $request->only('email', 'password');
$user = User::where('email', $credentials['email'])->first();
if (!$user) {
return response()->json(['message' => 'Email tidak ada di database!'], 409);
}
if (!Hash::check($credentials['password'], $user->password)) {
return response()->json(['message' => 'Password salah!'], 409);
}
if (Auth::attempt($credentials)) {
return response()->json(['message' => 'Berhasil Login!', 'redirect' => route('dashboard')], 201);
}
if (!Auth::attempt($credentials)) {
return response()->json(['message' => 'Gagal Login!'], 409);
}
}
return view('pages.auth.login', [
'title' => 'Login Page'
]);
}
public function register(Request $request)
{
if ($request->isMethod('post')) {
$data = $request->only(['name', 'email', 'password', 'phone']);
$data['password'] = Hash::make($data['password']);
$data['usertype'] = 'bk/guru';
$user = User::where('email', $data['email'])->first();
if ($user) {
return response()->json(['message' => 'Email sudah ada di database!'], 409);
}
User::create($data);
return response()->json(['message' => 'Berhasil daftar!', 'redirect' => route('login')], 201);
}
return view('pages.auth.register', [
'title' => 'Register Page'
]);
}
}

View File

@ -0,0 +1,8 @@
<?php
namespace App\Http\Controllers;
abstract class Controller
{
//
}

View File

@ -0,0 +1,106 @@
<?php
namespace App\Http\Controllers;
use App\Models\KriteriaPelanggaran;
use App\Models\Pelanggaran;
use App\Models\Siswa;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Storage;
class DashboardController extends Controller
{
public function index()
{
$data = Pelanggaran::all();
$groupedData = $data->groupBy('tingkat')->map(function ($group) {
return $group->count();
});
$formattedData = $groupedData->map(function ($value, $key) {
return ['label' => $key, 'value' => $value];
})->values();
return view('pages.dashboard.index', [
'title' => 'Dashboard',
'data' => $formattedData,
'countPelanggar' => Pelanggaran::distinct('id_siswa')->count('id_siswa'),
'countSiswa' => Siswa::count(),
'countSubKriteria' => KriteriaPelanggaran::count(),
]);
}
public function updateProfile(Request $request)
{
$user = User::find(Auth::user()->id);
if ($request->isMethod('POST')) {
$request->validate([
'photo' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:2048',
'name' => 'required|string|max:255',
'email' => 'required|email|max:255|unique:users,email,' . $user->id,
'phone' => 'nullable|string|max:15',
]);
$data = $request->only(['name', 'email', 'phone']);
if ($request->hasFile('photo')) {
$photoPath = $request->file('photo')->store('photos', 'public');
$data['photo'] = $photoPath;
if ($user->photo) {
Storage::disk('public')->delete($user->photo);
}
}
if (!$user->update($data)) {
return redirect()->back()->withInput()->withErrors('error', 'Gagal update profile');
}
return redirect()->to('dashboard/profile')->with('success', 'Berhasil update profile!');
}
return view('pages.dashboard.profile', [
'title' => 'Update Profile',
'data' => User::find(Auth::user()->id),
]);
}
public function updatePassword(Request $request)
{
if ($request->isMethod('POST')) {
$request->validate([
'old_password' => 'required',
'new_password' => 'required|confirmed',
]);
$user = User::find(Auth::id());
$old_password = $request->old_password;
$new_password = $request->new_password;
if (!Hash::check($old_password, $user->password)) {
return redirect()->route('profile.update')->with('error', 'Gagal update password: Password lama salah.');
}
$user->password = Hash::make($new_password);
$user->save();
return redirect()->route('profile.update')->with('success', 'Berhasil update password');
}
}
public function logout()
{
Auth::logout();
return response()->json([
'message' => 'Berhasil Logout!',
'code' => 201,
'redirect' => route('login')
]);
}
}

View File

@ -0,0 +1,83 @@
<?php
namespace App\Http\Controllers;
use App\Models\JenisPelanggaran;
use App\Models\KriteriaPelanggaran;
use Illuminate\Http\Request;
class JenisPelanggaranController extends Controller
{
public function index()
{
$kriteria = KriteriaPelanggaran::all();
$totalBobot = $kriteria->sum('bobot');
return view('pages.dashboard.jenispelanggaran.index', [
'title' => 'Data Kriteria Pelanggaran',
'totalBobot' => $totalBobot,
'jenis' => JenisPelanggaran::with('kriteria')->get(),
'kriteria' => KriteriaPelanggaran::all(),
]);
}
public function create(Request $request)
{
if ($request->isMethod('POST')) {
$request->validate([
'kode_kriteria' => 'required|string|max:255',
'jenis_pelanggaran' => 'required|string|max:255',
'point' => 'required|string|max:255',
]);
$data = $request->only(['kode_kriteria', 'jenis_pelanggaran', 'point']);
if (!JenisPelanggaran::create($data)) {
return redirect()->back()->withInput()->withErrors('error', 'Gagal menambah jenis pelanggaran');
}
return redirect()->route('jenispelanggaran')->with('success', 'Berhasil menambah jenis pelanggaran');
}
return view('pages.dashboard.jenispelanggaran.create', [
'title' => 'Tambah Jenis Pelanggaran',
'kriteria' => KriteriaPelanggaran::all(),
]);
}
public function update(Request $request, $id)
{
$jenispelanggaran = JenisPelanggaran::find($id);
if ($request->isMethod('POST')) {
$data = $request->only(['kode_kriteria', 'jenis_pelanggaran', 'point']);
$request->validate([
'kode_kriteria' => 'required|string|max:255',
'jenis_pelanggaran' => 'required|string|max:255',
'point' => 'required|string|max:255',
]);
if (!$jenispelanggaran->update($data)) {
return redirect()->back()->withInput()->withErrors('error', 'Gagal menambah jenis pelanggaran');
}
return redirect()->route('jenispelanggaran')->with('success', 'Berhasil update jenis pelanggaran!');
}
return view('pages.dashboard.jenispelanggaran.update', [
'title' => 'Perbarui Jenis Pelanggaran',
'data' => $jenispelanggaran,
'kriteria' => KriteriaPelanggaran::all(),
]);
}
public function delete($id)
{
$data = JenisPelanggaran::findOrFail($id);
if (!$data->delete()) {
return redirect()->route('jenispelanggaran')->with('error', 'Gagal hapus jenis pelanggaran!');
}
return redirect()->route('jenispelanggaran')->with('success', 'Berhasil hapus jenis pelanggaran!');
}
}

View File

@ -0,0 +1,84 @@
<?php
namespace App\Http\Controllers;
use App\Models\KriteriaPelanggaran;
use Illuminate\Http\Request;
class KriteriaPelanggaranController extends Controller
{
public function create(Request $request)
{
if ($request->isMethod('POST')) {
$request->validate([
'kriteria' => 'required|string|max:255',
'bobot' => 'required|numeric|min:0|max:100',
]);
$currentTotalBobot = KriteriaPelanggaran::sum('bobot');
$newBobot = $request->input('bobot');
if ($currentTotalBobot + $newBobot > 100) {
return redirect()->back()->withInput()->withErrors('error', 'Total persentasi bobot tidak boleh melebihi 100%.');
}
$latestCode = KriteriaPelanggaran::max('kode');
$lastNumber = intval(substr($latestCode, 1));
$nextCode = 'C' . ($lastNumber + 1);
$data = $request->only(['kriteria', 'bobot']);
$data['kode'] = $nextCode;
if (!KriteriaPelanggaran::create($data)) {
return redirect()->back()->withInput()->withErrors('error', 'Gagal menambah kriteria pelanggaran');
}
return redirect()->route('jenispelanggaran')->with('success', 'Berhasil menambah kriteria pelanggaran');
}
$currentTotalBobot = KriteriaPelanggaran::sum('bobot');
$remainingBobot = 100 - $currentTotalBobot;
return view('pages.dashboard.kriteriapelanggaran.create', [
'title' => 'Tambah Kriteria Pelanggaran',
'kriteria' => KriteriaPelanggaran::all(),
'remainingBobot' => $remainingBobot,
]);
}
public function update(Request $request, $id)
{
$kriteriapelanggaran = KriteriaPelanggaran::find($id);
if ($request->isMethod('POST')) {
$request->validate([
'kriteria' => 'required|string|max:255',
'bobot' => 'required|string|max:255',
]);
$data = $request->only(['kriteria', 'bobot']);
if (!$kriteriapelanggaran->update($data)) {
return redirect()->back()->withInput()->withErrors('error', 'Gagal menambah kriteria pelanggaran');
}
return redirect()->route('jenispelanggaran')->with('success', 'Berhasil update kriteriapelanggaran!');
}
return view('pages.dashboard.kriteriapelanggaran.update', [
'title' => 'Perbarui Kriteria Pelanggaran',
'data' => $kriteriapelanggaran,
]);
}
public function delete($id)
{
$data = KriteriaPelanggaran::findOrFail($id);
if (!$data->delete()) {
return redirect()->route('jenispelanggaran')->with('success', 'Berhasil hapus kriteria pelanggaran!');
}
return redirect()->route('jenispelanggaran')->with('success', 'Berhasil hapus kriteria pelanggaran!');
}
}

View File

@ -0,0 +1,305 @@
<?php
namespace App\Http\Controllers;
use App\Models\JenisPelanggaran;
use App\Models\KriteriaPelanggaran;
use App\Models\ListPelanggaran;
use App\Models\Pelanggaran;
use App\Models\Sanksi;
use App\Models\Siswa;
use App\Models\Tindakan;
use Illuminate\Http\Request;
class PelanggaranController extends Controller
{
public function index()
{
$data = Pelanggaran::with('listPelanggaran', 'siswa', 'tindakan', 'sanksi')
->orderBy('updated_at', 'desc') // Menambahkan pengurutan berdasarkan updated_at secara descending
->get();
return view('pages.dashboard.pelanggaran.index', [
'title' => 'Pelanggaran Siswa',
'data' => $data,
]);
}
function parseRange($range)
{
$parts = explode('-', $range);
if (count($parts) === 2) {
return [
'min' => (float) trim($parts[0]),
'max' => (float) trim($parts[1]),
];
}
return null;
}
public function create(Request $request)
{
if ($request->isMethod('POST')) {
$request->validate([
'id_siswa' => 'required|string|max:255',
'id_kriteria' => 'required|array',
'id_kriteria.*' => 'exists:kriteria_pelanggaran,id',
'id_jenis' => 'required|array',
'id_jenis.*' => 'exists:jenis_pelanggaran,id',
]);
try {
$idSiswa = $request->input('id_siswa');
$idKriteria = $request->input('id_kriteria');
$idJenis = $request->input('id_jenis');
$normalisasi = [];
foreach ($idKriteria as $kriteriaId) {
$kriteria = KriteriaPelanggaran::findOrFail($kriteriaId);
$normalisasi[$kriteria->kode][] = $kriteria->bobot / 100;
}
$utility = [];
foreach ($idJenis as $jenisId) {
$jenis = JenisPelanggaran::findOrFail($jenisId);
$utility[$jenis->kode_kriteria][] = intval($jenis->point);
}
$result = [];
foreach ($normalisasi as $kode => $values1) {
if (isset($utility[$kode])) {
$values2 = $utility[$kode];
if (count($values1) === count($values2)) {
$result[$kode] = [];
for ($i = 0; $i < count($values1); $i++) {
$result[$kode][] = $values1[$i] * $values2[$i];
}
} else {
$result[$kode] = null;
}
}
}
$summedResults = [];
foreach ($result as $kode => $values) {
if (is_array($values)) {
$summedResults[$kode] = array_sum($values);
} else {
$summedResults[$kode] = null;
}
}
$overallScore = array_sum($summedResults);
$tindakan = Tindakan::all()->first(function ($tindakan) use ($overallScore) {
$range = $this->parseRange($tindakan->rentang_point);
if (!$range) {
return redirect()->route('pelanggaran')->with('error', 'Rentang point does not exist for Tindakan');
}
return $overallScore >= $range['min'] && $overallScore <= $range['max'];
});
$sanksi = Sanksi::all()->first(function ($sanksi) use ($overallScore) {
$range = $this->parseRange($sanksi->rentang_point);
if (!$range) {
return redirect()->route('pelanggaran')->with('error', 'Rentang point does not exist for Sanksi');
}
return $overallScore >= $range['min'] && $overallScore <= $range['max'];
});
$tingkat = '';
if ($overallScore >= 1 && $overallScore <= 2) {
$tingkat = 'Pelanggaran Ringan';
} elseif ($overallScore >= 2.1 && $overallScore <= 8) {
$tingkat = 'Pelanggaran Sedang';
} elseif ($overallScore >= 8.1 && $overallScore <= 20) {
$tingkat = 'Tindak Pidana Ringan (TIPIRING)';
} elseif ($overallScore >= 20.1 && $overallScore <= 100) {
$tingkat = 'Tindak Pidana Berat (TIPIRAT)';
} else {
return redirect()->route('pelanggaran')->with('error', 'Skor melebihi 100, silahkan kurangi kriteria');
}
$pelanggaran = Pelanggaran::create([
'id_siswa' => $idSiswa,
'id_tindakan' => $tindakan->id,
'id_sanksi' => $sanksi->id,
'tingkat' => $tingkat,
]);
if (!$pelanggaran) {
return redirect()->route('pelanggaran')->with('error', 'gagal membuat pelanggaran');
}
foreach ($idKriteria as $index => $idKriteriaItem) {
ListPelanggaran::create([
'pelanggaran_id' => $pelanggaran->id,
'id_kriteria' => $idKriteriaItem,
'id_jenis' => $idJenis[$index],
]);
}
return redirect()->route('pelanggaran')->with('success', 'Berhasil menambah pelanggaran');
} catch (\Exception $e) {
return redirect()->back()->withInput()->withErrors('error', 'Gagal menambah pelanggaran');
}
}
return view('pages.dashboard.pelanggaran.create', [
'title' => 'Tambah Pelanggaran',
'siswa' => Siswa::all(),
'kriteria_pelanggaran' => KriteriaPelanggaran::with('jenis')->get(),
]);
}
public function update(Request $request, $id)
{
if ($request->isMethod('POST')) {
$request->validate([
'id_siswa' => 'required|string|max:255',
'id_kriteria' => 'required|array',
'id_kriteria.*' => 'exists:kriteria_pelanggaran,id',
'id_jenis' => 'required|array',
'id_jenis.*' => 'exists:jenis_pelanggaran,id',
]);
try {
$idSiswa = $request->input('id_siswa');
$idKriteria = $request->input('id_kriteria');
$idJenis = $request->input('id_jenis');
$normalisasi = [];
foreach ($idKriteria as $kriteriaId) {
$kriteria = KriteriaPelanggaran::findOrFail($kriteriaId);
$normalisasi[$kriteria->kode][] = $kriteria->bobot / 100;
}
$utility = [];
foreach ($idJenis as $jenisId) {
$jenis = JenisPelanggaran::findOrFail($jenisId);
$utility[$jenis->kode_kriteria][] = intval($jenis->point);
}
$result = [];
foreach ($normalisasi as $kode => $values1) {
if (isset($utility[$kode])) {
$values2 = $utility[$kode];
if (count($values1) === count($values2)) {
$result[$kode] = [];
for ($i = 0; $i < count($values1); $i++) {
$result[$kode][] = $values1[$i] * $values2[$i];
}
} else {
$result[$kode] = null;
}
}
}
$summedResults = [];
foreach ($result as $kode => $values) {
if (is_array($values)) {
$summedResults[$kode] = array_sum($values);
} else {
$summedResults[$kode] = null;
}
}
$overallScore = array_sum($summedResults);
$tindakan = Tindakan::all()->first(function ($tindakan) use ($overallScore) {
$range = $this->parseRange($tindakan->rentang_point);
if (!$range) {
return redirect()->route('pelanggaran')->with('error', 'Rentang point does not exist for Tindakan');
}
return $overallScore >= $range['min'] && $overallScore <= $range['max'];
});
$sanksi = Sanksi::all()->first(function ($sanksi) use ($overallScore) {
$range = $this->parseRange($sanksi->rentang_point);
if (!$range) {
return redirect()->route('pelanggaran')->with('error', 'Rentang point does not exist for Sanksi');
}
return $overallScore >= $range['min'] && $overallScore <= $range['max'];
});
$tingkat = '';
if ($overallScore >= 1 && $overallScore <= 2) {
$tingkat = 'Pelanggaran Ringan';
} elseif ($overallScore >= 2.1 && $overallScore <= 8) {
$tingkat = 'Pelanggaran Sedang';
} elseif ($overallScore >= 8.1 && $overallScore <= 20) {
$tingkat = 'Tindak Pidana Ringan (TIPIRING)';
} elseif ($overallScore >= 20.1 && $overallScore <= 100) {
$tingkat = 'Tindak Pidana Berat (TIPIRAT)';
} else {
return redirect()->route('pelanggaran')->with('error', 'Skor melebihi 100, silahkan kurangi kriteria');
}
$pelanggaran = Pelanggaran::findOrFail($id);
$pelanggaran->update([
'id_siswa' => $idSiswa,
'id_tindakan' => $tindakan->id,
'id_sanksi' => $sanksi->id,
'tingkat' => $tingkat,
]);
$pelanggaran->listPelanggaran()->delete();
foreach ($idKriteria as $index => $idKriteriaItem) {
ListPelanggaran::create([
'pelanggaran_id' => $pelanggaran->id,
'id_kriteria' => $idKriteriaItem,
'id_jenis' => $idJenis[$index],
]);
}
return redirect()->route('pelanggaran')->with('success', 'Berhasil memperbarui pelanggaran');
} catch (\Exception $e) {
return redirect()->back()->withInput()->withErrors('error', 'Gagal memperbarui pelanggaran');
}
}
return view('pages.dashboard.pelanggaran.update', [
'title' => 'Edit Pelanggaran',
'siswa' => Siswa::all(),
'kriteria_pelanggaran' => KriteriaPelanggaran::with('jenis')->get(),
'pelanggaran' => Pelanggaran::findOrFail($id),
]);
}
public function detail($id)
{
$pelanggaran = Pelanggaran::with('sanksi', 'tindakan', 'siswa')->where('id', $id)->first();
//dd($pelanggaran);
return view('pages.dashboard.pelanggaran.detail', [
'title' => 'Pelanggaran Siswa',
'data' => $pelanggaran,
'list' => ListPelanggaran::with('kriteria', 'jenis')->where('pelanggaran_id', $pelanggaran->id)->get(),
]);
}
public function delete($id)
{
$data = Pelanggaran::findOrFail($id);
$listPelanggaran = ListPelanggaran::where('pelanggaran_id', $data->id)->get();
foreach($listPelanggaran as $item) {
$pelanggaran = ListPelanggaran::find($item->id);
$pelanggaran->delete();
}
if (!$data->delete()) {
return redirect()->route('pelanggaran')->with(['error' => 'Gagal hapus pelanggaran!']);
}
return redirect()->route('pelanggaran')->with(['success' => 'Berhasil hapus pelanggaran!']);
}
}

View File

@ -0,0 +1,101 @@
<?php
namespace App\Http\Controllers;
use App\Models\Sanksi;
use Illuminate\Http\Request;
class SanksiController extends Controller
{
/**
* Generate a unique code with a specified prefix.
*
* @param string $prefix
* @return string
*/
private function generateUniqueCode($prefix)
{
$latestCode = Sanksi::where('kode_sanksi', 'like', $prefix . '%')
->orderBy('kode_sanksi', 'desc')
->first();
$counter = $latestCode ? intval(substr($latestCode->kode_sanksi, strlen($prefix))) + 1 : 1;
$code = $prefix . str_pad($counter, STR_PAD_LEFT);
return $code;
}
public function index()
{
return view('pages.dashboard.sanksi.index', [
'title' => 'Data Sanksi',
'data' => Sanksi::all(),
]);
}
public function create(Request $request)
{
if ($request->isMethod('POST')) {
$request->validate([
'rentang_point' => 'required|string|max:255',
'jenis_sanksi' => 'required|string|max:255',
]);
$data = $request->only(['rentang_point', 'jenis_sanksi']);
$prefix = 'S';
$code = $this->generateUniqueCode($prefix);
$data['kode_sanksi'] = $code;
if (!Sanksi::create($data)) {
return redirect()->back()->withInput()->withErrors(['error' => 'Gagal menambah sanksi']);
}
return redirect()->route('sanksi')->with('success', 'Berhasil menambah sanksi');
}
return view('pages.dashboard.sanksi.create', [
'title' => 'Tambah Sanksi',
]);
}
public function update(Request $request, $id)
{
$sanksi = Sanksi::find($id);
if ($request->isMethod('POST')) {
$data = $request->only(['rentang_point', 'jenis_sanksi']);
$rules = [
'rentang_point' => 'required|string|max:255',
'jenis_sanksi' => 'required|string|max:255',
];
$request->validate($rules);
if (!$sanksi->update($data)) {
return redirect()->back()->withInput()->withErrors(['error' => 'Gagal menambah sanksi']);
}
return redirect()->route('sanksi')->with(['success' => 'Berhasil update sanksi!']);
}
return view('pages.dashboard.sanksi.update', [
'title' => 'Perbarui Sanksi',
'data' => $sanksi,
]);
}
public function delete($id)
{
$data = Sanksi::findOrFail($id);
if (!$data->delete()) {
return redirect()->route('sanksi')->with(['error' => 'Gagal hapus sanksi!']);
}
return redirect()->route('sanksi')->with(['success' => 'Berhasil hapus sanksi!']);
}
}

View File

@ -0,0 +1,98 @@
<?php
namespace App\Http\Controllers;
use App\Models\ListPelanggaran;
use App\Models\Pelanggaran;
use App\Models\Siswa;
use App\Models\User;
use Illuminate\Http\Request;
class SiswaController extends Controller
{
public function index()
{
return view('pages.dashboard.siswa.index', [
'title' => 'Data Siswa',
'data' => Siswa::with('walikelas')->get(),
]);
}
public function create(Request $request)
{
if ($request->isMethod('POST')) {
$data = $request->only(['nama', 'nis', 'kelas', 'wali_kelas_id']);
$request->validate([
'nama' => 'required|string|max:255',
'nis' => 'required|numeric|unique:siswa,nis',
'kelas' => 'required|string|max:255',
'wali_kelas_id' => 'required|numeric',
]);
if (!Siswa::create($data)) {
return redirect()->back()->withInput()->withErrors(['error' => 'Gagal menambah siswa']);
}
return redirect()->route('siswa')->with('success', 'Berhasil menambah siswa');
}
return view('pages.dashboard.siswa.create', [
'title' => 'Tambah Siswa',
'wali' => User::where('usertype', 'bk/guru')->get()
]);
}
public function update(Request $request, $id)
{
$siswa = Siswa::with('walikelas')->find($id);
if ($request->isMethod('POST')) {
$data = $request->only(['nama', 'nis', 'kelas', 'wali_kelas']);
$rules = [
'nama' => 'required|string|max:255',
'nis' => 'required|numeric|unique:siswa,nis,' . $siswa->id,
'kelas' => 'required|string|max:255',
'wali_kelas_id' => 'required|numeric',
];
$request->validate($rules);
if (!$siswa->update($data)) {
return redirect()->back()->withInput()->withErrors(['error' => 'Gagal menambah siswa']);
}
return redirect()->route('siswa')->with(['success' => 'Berhasil update siswa!']);
}
return view('pages.dashboard.siswa.update', [
'title' => 'Perbarui Siswa',
'data' => $siswa,
'wali' => User::where('usertype', 'bk/guru')->get()
]);
}
public function delete($id)
{
$data = Siswa::findOrFail($id);
$pelanggaran = Pelanggaran::where('id_siswa', $id)->get();
foreach ($pelanggaran as $pel) {
$listPelanggaran = ListPelanggaran::where('pelanggaran_id', $pel->id)->get();
foreach ($listPelanggaran as $item) {
$item->delete();
}
$pel->delete();
}
if (!$data->delete()) {
return redirect()->route('siswa')->with(['error' => 'Gagal hapus siswa!']);
}
return redirect()->route('siswa')->with(['success' => 'Berhasil hapus siswa!']);
}
}

View File

@ -0,0 +1,102 @@
<?php
namespace App\Http\Controllers;
use App\Models\Tindakan;
use Illuminate\Http\Request;
class TindakanController extends Controller
{
/**
* Generate a unique code with a specified prefix.
*
* @param string $prefix
* @return string
*/
private function generateUniqueCode($prefix)
{
$latestCode = Tindakan::where('kode_tindakan', 'like', $prefix . '%')
->orderBy('kode_tindakan', 'desc')
->first();
$counter = $latestCode ? intval(substr($latestCode->kode_tindakan, strlen($prefix))) + 1 : 1;
$code = $prefix . str_pad($counter, STR_PAD_LEFT);
return $code;
}
public function index()
{
return view('pages.dashboard.tindakan.index', [
'title' => 'Data Tindakan',
'data' => Tindakan::all(),
]);
}
public function create(Request $request)
{
if ($request->isMethod('POST')) {
$request->validate([
'rentang_point' => 'required|string|max:255',
'tindakan_sekolah' => 'required|string|max:255',
]);
$data = $request->only(['rentang_point', 'tindakan_sekolah']);
$prefix = 'T';
$code = $this->generateUniqueCode($prefix);
$data = $request->only(['rentang_point', 'tindakan_sekolah']);
$data['kode_tindakan'] = $code;
if (!Tindakan::create($data)) {
return redirect()->back()->withInput()->withErrors(['error' => 'Gagal menambah tindakan']);
}
return redirect()->route('tindakan')->with('success', 'Berhasil menambah tindakan');
}
return view('pages.dashboard.tindakan.create', [
'title' => 'Tambah Tindakan',
]);
}
public function update(Request $request, $id)
{
$tindakan = Tindakan::find($id);
if ($request->isMethod('POST')) {
$data = $request->only(['rentang_point', 'tindakan_sekolah']);
$rules = [
'rentang_point' => 'required|string|max:255',
'tindakan_sekolah' => 'required|string|max:255',
];
$request->validate($rules);
if (!$tindakan->update($data)) {
return redirect()->back()->withInput()->withErrors(['error' => 'Gagal menambah tindakan']);
}
return redirect()->route('tindakan')->with(['success' => 'Berhasil update tindakan!']);
}
return view('pages.dashboard.tindakan.update', [
'title' => 'Perbarui Tindakan',
'data' => $tindakan,
]);
}
public function delete($id)
{
$data = Tindakan::findOrFail($id);
if (!$data->delete()) {
return redirect()->route('tindakan')->with(['error' => 'Gagal hapus tindakan!']);
}
return redirect()->route('tindakan')->with(['success' => 'Berhasil hapus tindakan!']);
}
}

View File

@ -0,0 +1,88 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\User;
use Illuminate\Support\Facades\Hash;
class UserController extends Controller
{
public function index()
{
return view('pages.dashboard.user.index', [
'title' => 'Data Pengguna',
'data' => User::all(),
]);
}
public function create(Request $request)
{
if ($request->isMethod('POST')) {
$data = [
'name' => $request->name,
'email' => $request->email,
'phone' => $request->phone,
'usertype' => $request->usertype,
'password' => Hash::make($request->password),
];
$request->validate([
'name' => 'required|string|max:255',
'email' => 'required|email|unique:users,email',
'phone' => 'required|numeric|unique:users,phone',
'usertype' => 'required|string|in:admin,bk/guru',
'password' => 'required|string|min:8|confirmed',
]);
if (!User::create($data)) {
return redirect()->back()->withInput()->withErrors(['error' => 'Gagal menambah pengguna']);
}
return redirect()->route('user')->with('success', 'Berhasil menambah pengguna');
}
return view('pages.dashboard.user.create', [
'title' => 'Tambah Pengguna',
]);
}
public function update(Request $request, $id)
{
$user = User::find($id);
if ($request->isMethod('POST')) {
$data = $request->only(['name', 'email', 'phone', 'usertype']);
$rules = [
'name' => 'required|string|max:255',
'email' => 'required|email|unique:users,email,' . $user->id,
'phone' => 'required|numeric|unique:users,phone,' . $user->id,
'usertype' => 'required|string|in:admin,bk/guru',
];
$request->validate($rules);
if (!$user->update($data)) {
return redirect()->back()->withInput()->withErrors(['error' => 'Gagal menambah pengguna']);
}
return redirect()->route('user')->with(['success' => 'Berhasil update pengguna!']);
}
return view('pages.dashboard.user.update', [
'title' => 'Perbarui Pengguna',
'data' => $user,
]);
}
public function delete($id)
{
$data = User::findOrFail($id);
if (!$data->delete()) {
return redirect()->route('user')->with(['error' => 'Gagal hapus pengguna!']);
}
return redirect()->route('user')->with(['success' => 'Berhasil hapus pengguna!']);
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class isAuthenticatedAs
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next, string $role): Response
{
if ($request->user()->usertype !== $role) {
return redirect()->route('dashboard')->with('error', 'Akses dilarang.');
}
return $next($request);
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class JenisPelanggaran extends Model
{
use HasFactory;
protected $table = 'jenis_pelanggaran';
protected $guarded = [];
public function kriteria()
{
return $this->belongsTo(KriteriaPelanggaran::class, 'kode_kriteria', 'kode');
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class KriteriaPelanggaran extends Model
{
use HasFactory;
protected $table = 'kriteria_pelanggaran';
protected $guarded = [];
public function jenis()
{
return $this->hasMany(JenisPelanggaran::class, 'kode_kriteria', 'kode');
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ListPelanggaran extends Model
{
use HasFactory;
protected $table = 'list_pelanggaran';
protected $guarded = [];
public function kriteria()
{
return $this->belongsTo(KriteriaPelanggaran::class, 'id_kriteria', 'id');
}
public function jenis()
{
return $this->belongsTo(JenisPelanggaran::class, 'id_jenis', 'id');
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Pelanggaran extends Model
{
use HasFactory;
protected $table = 'pelanggaran';
protected $guarded = [];
public function listPelanggaran()
{
return $this->hasMany(ListPelanggaran::class)->with('kriteria', 'jenis');
}
public function siswa()
{
return $this->belongsTo(Siswa::class, 'id_siswa', 'id');
}
public function tindakan()
{
return $this->belongsTo(Tindakan::class, 'id_tindakan', 'id');
}
public function sanksi()
{
return $this->belongsTo(Sanksi::class, 'id_sanksi', 'id');
}
}

14
app/Models/Sanksi.php Normal file
View File

@ -0,0 +1,14 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Sanksi extends Model
{
use HasFactory;
protected $table = 'sanksi';
protected $guarded = [];
}

19
app/Models/Siswa.php Normal file
View File

@ -0,0 +1,19 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Siswa extends Model
{
use HasFactory;
protected $table = 'siswa';
protected $guarded = [];
public function walikelas()
{
return $this->belongsTo(User::class, 'wali_kelas_id');
}
}

14
app/Models/Tindakan.php Normal file
View File

@ -0,0 +1,14 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Tindakan extends Model
{
use HasFactory;
protected $table = 'tindakan';
protected $guarded = [];
}

50
app/Models/User.php Normal file
View File

@ -0,0 +1,50 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
'phone',
'photo',
'usertype'
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
//
}
}

15
artisan Normal file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env php
<?php
use Symfony\Component\Console\Input\ArgvInput;
define('LARAVEL_START', microtime(true));
// Register the Composer autoloader...
require __DIR__.'/vendor/autoload.php';
// Bootstrap Laravel and handle the command...
$status = (require_once __DIR__.'/bootstrap/app.php')
->handleCommand(new ArgvInput);
exit($status);

21
bootstrap/app.php Normal file
View File

@ -0,0 +1,21 @@
<?php
use App\Http\Middleware\isAuthenticatedAs;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
$middleware->alias([
'isAuthenticatedAs' => isAuthenticatedAs::class
]);
})
->withExceptions(function (Exceptions $exceptions) {
//
})->create();

2
bootstrap/cache/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

5
bootstrap/providers.php Normal file
View File

@ -0,0 +1,5 @@
<?php
return [
App\Providers\AppServiceProvider::class,
];

66
composer.json Normal file
View File

@ -0,0 +1,66 @@
{
"name": "laravel/laravel",
"type": "project",
"description": "The skeleton application for the Laravel framework.",
"keywords": ["laravel", "framework"],
"license": "MIT",
"require": {
"php": "^8.2",
"laravel/framework": "^11.0",
"laravel/tinker": "^2.9"
},
"require-dev": {
"fakerphp/faker": "^1.23",
"laravel/pint": "^1.13",
"laravel/sail": "^1.26",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.0",
"phpunit/phpunit": "^11.0.1",
"spatie/laravel-ignition": "^2.4"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi",
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
"@php artisan migrate --graceful --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
}

8153
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

126
config/app.php Normal file
View File

@ -0,0 +1,126 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application, which will be used when the
| framework needs to place the application's name in a notification or
| other UI elements where an application name needs to be displayed.
|
*/
'name' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => (bool) env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| the application so that it's available within Artisan commands.
|
*/
'url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. The timezone
| is set to "UTC" by default as it is suitable for most use cases.
|
*/
'timezone' => env('APP_TIMEZONE', 'UTC'),
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by Laravel's translation / localization methods. This option can be
| set to any locale for which you plan to have translation strings.
|
*/
'locale' => env('APP_LOCALE', 'en'),
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is utilized by Laravel's encryption services and should be set
| to a random, 32 character string to ensure that all encrypted values
| are secure. You should do this prior to deploying the application.
|
*/
'cipher' => 'AES-256-CBC',
'key' => env('APP_KEY'),
'previous_keys' => [
...array_filter(
explode(',', env('APP_PREVIOUS_KEYS', ''))
),
],
/*
|--------------------------------------------------------------------------
| Maintenance Mode Driver
|--------------------------------------------------------------------------
|
| These configuration options determine the driver used to determine and
| manage Laravel's "maintenance mode" status. The "cache" driver will
| allow maintenance mode to be controlled across multiple machines.
|
| Supported drivers: "file", "cache"
|
*/
'maintenance' => [
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
'store' => env('APP_MAINTENANCE_STORE', 'database'),
],
];

115
config/auth.php Normal file
View File

@ -0,0 +1,115 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option defines the default authentication "guard" and password
| reset "broker" for your application. You may change these values
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => env('AUTH_GUARD', 'web'),
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| which utilizes session storage plus the Eloquent user provider.
|
| All authentication guards have a user provider, which defines how the
| users are actually retrieved out of your database or other storage
| system used by the application. Typically, Eloquent is utilized.
|
| Supported: "session"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication guards have a user provider, which defines how the
| users are actually retrieved out of your database or other storage
| system used by the application. Typically, Eloquent is utilized.
|
| If you have multiple user tables or models you may configure multiple
| providers to represent the model / table. These providers may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => env('AUTH_MODEL', App\Models\User::class),
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| These configuration options specify the behavior of Laravel's password
| reset functionality, including the table utilized for token storage
| and the user provider that is invoked to actually retrieve users.
|
| The expiry time is the number of minutes that each reset token will be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
| The throttle setting is the number of seconds a user must wait before
| generating more password reset tokens. This prevents the user from
| quickly generating a very large amount of password reset tokens.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
'expire' => 60,
'throttle' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the amount of seconds before a password confirmation
| window expires and users are asked to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
];

107
config/cache.php Normal file
View File

@ -0,0 +1,107 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache store that will be used by the
| framework. This connection is utilized if another isn't explicitly
| specified when running a cache operation inside the application.
|
*/
'default' => env('CACHE_STORE', 'database'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
| Supported drivers: "array", "database", "file", "memcached",
| "redis", "dynamodb", "octane", "null"
|
*/
'stores' => [
'array' => [
'driver' => 'array',
'serialize' => false,
],
'database' => [
'driver' => 'database',
'table' => env('DB_CACHE_TABLE', 'cache'),
'connection' => env('DB_CACHE_CONNECTION'),
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
'lock_path' => storage_path('framework/cache/data'),
],
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
],
'dynamodb' => [
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'endpoint' => env('DYNAMODB_ENDPOINT'),
],
'octane' => [
'driver' => 'octane',
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
| stores, there might be other applications using the same cache. For
| that reason, you may prefix every cache key to avoid collisions.
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
];

170
config/database.php Normal file
View File

@ -0,0 +1,170 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for database operations. This is
| the connection which will be utilized unless another connection
| is explicitly specified when you execute a query / statement.
|
*/
'default' => env('DB_CONNECTION', 'sqlite'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Below are all of the database connections defined for your application.
| An example configuration is provided for each database system which
| is supported by Laravel. You're free to add / remove connections.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DB_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
'mysql' => [
'driver' => 'mysql',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'mariadb' => [
'driver' => 'mariadb',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
'search_path' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DB_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run on the database.
|
*/
'migrations' => [
'table' => 'migrations',
'update_date_on_publish' => true,
],
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer body of commands than a typical key-value system
| such as Memcached. You may define your connection settings here.
|
*/
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
],
],
];

76
config/filesystems.php Normal file
View File

@ -0,0 +1,76 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application for file storage.
|
*/
'default' => env('FILESYSTEM_DISK', 'local'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Below you may configure as many filesystem disks as necessary, and you
| may even configure multiple disks for the same driver. Examples for
| most supported storage drivers are configured here for reference.
|
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
],
],
/*
|--------------------------------------------------------------------------
| Symbolic Links
|--------------------------------------------------------------------------
|
| Here you may configure the symbolic links that will be created when the
| `storage:link` Artisan command is executed. The array keys should be
| the locations of the links and the values should be their targets.
|
*/
'links' => [
public_path('storage') => storage_path('app/public'),
],
];

132
config/logging.php Normal file
View File

@ -0,0 +1,132 @@
<?php
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
use Monolog\Processor\PsrLogMessageProcessor;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that is utilized to write
| messages to your logs. The value provided here should match one of
| the channels present in the list of "channels" configured below.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Deprecations Log Channel
|--------------------------------------------------------------------------
|
| This option controls the log channel that should be used to log warnings
| regarding deprecated PHP and library features. This allows you to get
| your application ready for upcoming major versions of dependencies.
|
*/
'deprecations' => [
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
],
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Laravel
| utilizes the Monolog PHP logging library, which includes a variety
| of powerful log handlers and formatters that you're free to use.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog", "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => explode(',', env('LOG_STACK', 'single')),
'ignore_exceptions' => false,
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'replace_placeholders' => true,
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => env('LOG_DAILY_DAYS', 14),
'replace_placeholders' => true,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
'level' => env('LOG_LEVEL', 'critical'),
'replace_placeholders' => true,
],
'papertrail' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
],
'processors' => [PsrLogMessageProcessor::class],
],
'stderr' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => StreamHandler::class,
'formatter' => env('LOG_STDERR_FORMATTER'),
'with' => [
'stream' => 'php://stderr',
],
'processors' => [PsrLogMessageProcessor::class],
],
'syslog' => [
'driver' => 'syslog',
'level' => env('LOG_LEVEL', 'debug'),
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
'replace_placeholders' => true,
],
'errorlog' => [
'driver' => 'errorlog',
'level' => env('LOG_LEVEL', 'debug'),
'replace_placeholders' => true,
],
'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
],
'emergency' => [
'path' => storage_path('logs/laravel.log'),
],
],
];

116
config/mail.php Normal file
View File

@ -0,0 +1,116 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Mailer
|--------------------------------------------------------------------------
|
| This option controls the default mailer that is used to send all email
| messages unless another mailer is explicitly specified when sending
| the message. All additional mailers can be configured within the
| "mailers" array. Examples of each type of mailer are provided.
|
*/
'default' => env('MAIL_MAILER', 'log'),
/*
|--------------------------------------------------------------------------
| Mailer Configurations
|--------------------------------------------------------------------------
|
| Here you may configure all of the mailers used by your application plus
| their respective settings. Several examples have been configured for
| you and you are free to add your own as your application requires.
|
| Laravel supports a variety of mail "transport" drivers that can be used
| when delivering an email. You may specify which one you're using for
| your mailers below. You may also add additional mailers if needed.
|
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
| "postmark", "resend", "log", "array",
| "failover", "roundrobin"
|
*/
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'url' => env('MAIL_URL'),
'host' => env('MAIL_HOST', '127.0.0.1'),
'port' => env('MAIL_PORT', 2525),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN'),
],
'ses' => [
'transport' => 'ses',
],
'postmark' => [
'transport' => 'postmark',
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
// 'client' => [
// 'timeout' => 5,
// ],
],
'resend' => [
'transport' => 'resend',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
'failover' => [
'transport' => 'failover',
'mailers' => [
'smtp',
'log',
],
],
'roundrobin' => [
'transport' => 'roundrobin',
'mailers' => [
'ses',
'postmark',
],
],
],
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all emails sent by your application to be sent from
| the same address. Here you may specify a name and address that is
| used globally for all emails that are sent by your application.
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
];

112
config/queue.php Normal file
View File

@ -0,0 +1,112 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel's queue supports a variety of backends via a single, unified
| API, giving you convenient access to each backend using identical
| syntax for each. The default queue connection is defined below.
|
*/
'default' => env('QUEUE_CONNECTION', 'database'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection options for every queue backend
| used by your application. An example configuration is provided for
| each backend supported by Laravel. You're also free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'connection' => env('DB_QUEUE_CONNECTION'),
'table' => env('DB_QUEUE_TABLE', 'jobs'),
'queue' => env('DB_QUEUE', 'default'),
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
'after_commit' => false,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
'queue' => env('BEANSTALKD_QUEUE', 'default'),
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
'block_for' => 0,
'after_commit' => false,
],
'sqs' => [
'driver' => 'sqs',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'default'),
'suffix' => env('SQS_SUFFIX'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'after_commit' => false,
],
'redis' => [
'driver' => 'redis',
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
'block_for' => null,
'after_commit' => false,
],
],
/*
|--------------------------------------------------------------------------
| Job Batching
|--------------------------------------------------------------------------
|
| The following options configure the database and table that store job
| batching information. These options can be updated to any database
| connection and table which has been defined by your application.
|
*/
'batching' => [
'database' => env('DB_CONNECTION', 'sqlite'),
'table' => 'job_batches',
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control how and where failed jobs are stored. Laravel ships with
| support for storing failed jobs in a simple file or in a database.
|
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
*/
'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'sqlite'),
'table' => 'failed_jobs',
],
];

38
config/services.php Normal file
View File

@ -0,0 +1,38 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Mailgun, Postmark, AWS and more. This file provides the de facto
| location for this type of information, allowing packages to have
| a conventional file to locate the various service credentials.
|
*/
'postmark' => [
'token' => env('POSTMARK_TOKEN'),
],
'ses' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'resend' => [
'key' => env('RESEND_KEY'),
],
'slack' => [
'notifications' => [
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
],
],
];

217
config/session.php Normal file
View File

@ -0,0 +1,217 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option determines the default session driver that is utilized for
| incoming requests. Laravel supports a variety of storage options to
| persist session data. Database storage is a great default choice.
|
| Supported: "file", "cookie", "database", "apc",
| "memcached", "redis", "dynamodb", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'database'),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to expire immediately when the browser is closed then you may
| indicate that via the expire_on_close configuration option.
|
*/
'lifetime' => env('SESSION_LIFETIME', 120),
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
/*
|--------------------------------------------------------------------------
| Session Encryption
|--------------------------------------------------------------------------
|
| This option allows you to easily specify that all of your session data
| should be encrypted before it's stored. All encryption is performed
| automatically by Laravel and you may use the session like normal.
|
*/
'encrypt' => env('SESSION_ENCRYPT', false),
/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When utilizing the "file" session driver, the session files are placed
| on disk. The default storage location is defined here; however, you
| are free to provide another location where they should be stored.
|
*/
'files' => storage_path('framework/sessions'),
/*
|--------------------------------------------------------------------------
| Session Database Connection
|--------------------------------------------------------------------------
|
| When using the "database" or "redis" session drivers, you may specify a
| connection that should be used to manage these sessions. This should
| correspond to a connection in your database configuration options.
|
*/
'connection' => env('SESSION_CONNECTION'),
/*
|--------------------------------------------------------------------------
| Session Database Table
|--------------------------------------------------------------------------
|
| When using the "database" session driver, you may specify the table to
| be used to store sessions. Of course, a sensible default is defined
| for you; however, you're welcome to change this to another table.
|
*/
'table' => env('SESSION_TABLE', 'sessions'),
/*
|--------------------------------------------------------------------------
| Session Cache Store
|--------------------------------------------------------------------------
|
| When using one of the framework's cache driven session backends, you may
| define the cache store which should be used to store the session data
| between requests. This must match one of your defined cache stores.
|
| Affects: "apc", "dynamodb", "memcached", "redis"
|
*/
'store' => env('SESSION_STORE'),
/*
|--------------------------------------------------------------------------
| Session Sweeping Lottery
|--------------------------------------------------------------------------
|
| Some session drivers must manually sweep their storage location to get
| rid of old sessions from storage. Here are the chances that it will
| happen on a given request. By default, the odds are 2 out of 100.
|
*/
'lottery' => [2, 100],
/*
|--------------------------------------------------------------------------
| Session Cookie Name
|--------------------------------------------------------------------------
|
| Here you may change the name of the session cookie that is created by
| the framework. Typically, you should not need to change this value
| since doing so does not grant a meaningful security improvement.
|
*/
'cookie' => env(
'SESSION_COOKIE',
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
),
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The session cookie path determines the path for which the cookie will
| be regarded as available. Typically, this will be the root path of
| your application, but you're free to change this when necessary.
|
*/
'path' => env('SESSION_PATH', '/'),
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| This value determines the domain and subdomains the session cookie is
| available to. By default, the cookie will be available to the root
| domain and all subdomains. Typically, this shouldn't be changed.
|
*/
'domain' => env('SESSION_DOMAIN'),
/*
|--------------------------------------------------------------------------
| HTTPS Only Cookies
|--------------------------------------------------------------------------
|
| By setting this option to true, session cookies will only be sent back
| to the server if the browser has a HTTPS connection. This will keep
| the cookie from being sent to you when it can't be done securely.
|
*/
'secure' => env('SESSION_SECURE_COOKIE'),
/*
|--------------------------------------------------------------------------
| HTTP Access Only
|--------------------------------------------------------------------------
|
| Setting this value to true will prevent JavaScript from accessing the
| value of the cookie and the cookie will only be accessible through
| the HTTP protocol. It's unlikely you should disable this option.
|
*/
'http_only' => env('SESSION_HTTP_ONLY', true),
/*
|--------------------------------------------------------------------------
| Same-Site Cookies
|--------------------------------------------------------------------------
|
| This option determines how your cookies behave when cross-site requests
| take place, and can be used to mitigate CSRF attacks. By default, we
| will set this value to "lax" to permit secure cross-site requests.
|
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
| Supported: "lax", "strict", "none", null
|
*/
'same_site' => env('SESSION_SAME_SITE', 'lax'),
/*
|--------------------------------------------------------------------------
| Partitioned Cookies
|--------------------------------------------------------------------------
|
| Setting this value to true will tie the cookie to the top-level site for
| a cross-site context. Partitioned cookies are accepted by the browser
| when flagged "secure" and the Same-Site attribute is set to "none".
|
*/
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
];

1
database/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.sqlite*

View File

@ -0,0 +1,44 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}

View File

@ -0,0 +1,52 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->string('phone')->nullable();
$table->string('photo')->nullable();
$table->enum('usertype', ['bk/guru', 'admin'])->nullable();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration');
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};

View File

@ -0,0 +1,57 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('siswa', function (Blueprint $table) {
$table->id();
$table->string('nama');
$table->string('nis')->unique();
$table->string('kelas');
$table->unsignedBigInteger('wali_kelas_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('siswa');
}
};

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('tindakan', function (Blueprint $table) {
$table->id();
$table->string('kode_tindakan');
$table->string('rentang_point');
$table->string('tindakan_sekolah');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tindakan');
}
};

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('kriteria_pelanggaran', function (Blueprint $table) {
$table->id();
$table->string('kode')->unique();
$table->string('kriteria');
$table->string('bobot');
$table->timestamps();
});
Schema::create('jenis_pelanggaran', function (Blueprint $table) {
$table->id();
$table->string('kode_kriteria');
$table->string('jenis_pelanggaran');
$table->string('point');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('kriteria_pelanggaran');
Schema::dropIfExists('jenis_pelanggaran');
}
};

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('pelanggaran', function (Blueprint $table) {
$table->id();
$table->string('id_siswa');
$table->string('id_tindakan');
$table->string('id_sanksi');
$table->enum('tingkat', ['Pelanggaran Ringan', 'Pelanggaran Sedang', 'Tindak Pidana Ringan (TIPIRING)', 'Tindak Pidana Berat (TIPIRAT)']);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('pelanggaran');
}
};

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('sanksi', function (Blueprint $table) {
$table->id();
$table->string('kode_sanksi');
$table->string('rentang_point');
$table->string('jenis_sanksi');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('sanksi');
}
};

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('list_pelanggaran', function (Blueprint $table) {
$table->id();
$table->string('pelanggaran_id');
$table->string('id_kriteria');
$table->string('id_jenis');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('list_pelanggaran');
}
};

2425
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

20
package.json Normal file
View File

@ -0,0 +1,20 @@
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"autoprefixer": "^10.4.19",
"axios": "^1.6.4",
"laravel-vite-plugin": "^1.0",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.3",
"vite": "^5.0"
},
"dependencies": {
"alpinejs": "^3.13.10",
"chart.js": "^4.4.3"
}
}

33
phpunit.xml Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory>tests/Feature</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>app</directory>
</include>
</source>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_STORE" value="array"/>
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
<env name="MAIL_MAILER" value="array"/>
<env name="PULSE_ENABLED" value="false"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="TELESCOPE_ENABLED" value="false"/>
</php>
</phpunit>

6
postcss.config.js Normal file
View File

@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

21
public/.htaccess Normal file
View File

@ -0,0 +1,21 @@
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

3
public/assets/js/app.js Normal file
View File

@ -0,0 +1,3 @@
function confirmDelete() {
return confirm('Are you sure you want to delete this record?');
}

0
public/favicon.ico Normal file
View File

17
public/index.php Normal file
View File

@ -0,0 +1,17 @@
<?php
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
require $maintenance;
}
// Register the Composer autoloader...
require __DIR__.'/../vendor/autoload.php';
// Bootstrap Laravel and handle the request...
(require_once __DIR__.'/../bootstrap/app.php')
->handleRequest(Request::capture());

2
public/robots.txt Normal file
View File

@ -0,0 +1,2 @@
User-agent: *
Disallow:

3
resources/css/app.css Normal file
View File

@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

7
resources/js/app.js Normal file
View File

@ -0,0 +1,7 @@
import './bootstrap';
import Alpine from 'alpinejs';
import Chart from 'chart.js/auto';
window.Alpine = Alpine
Alpine.start()

4
resources/js/bootstrap.js vendored Normal file
View File

@ -0,0 +1,4 @@
import axios from 'axios';
window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

View File

@ -0,0 +1,15 @@
<div x-cloak x-data="{ showSuccess: @if(session('success')) true @else false @endif }" x-init="setTimeout(() => { showSuccess = false; }, 5000)" x-show="showSuccess" x-transition:enter="transition ease-out duration-300" x-transition:enter-start="opacity-0 transform scale-90" x-transition:enter-end="opacity-100 transform scale-100" x-transition:leave="transition ease-in duration-200" x-transition:leave-start="opacity-100 transform scale-100" x-transition:leave-end="opacity-0 transform scale-90" class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative mb-4" role="alert">
<strong class="font-bold">Success!</strong>
<span class="block sm:inline">{{ session('success') }}</span>
<span class="absolute top-0 bottom-0 right-0 px-4 py-3">
<svg x-on:click="showSuccess = false" class="fill-current h-6 w-6 text-green-500" role="button" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><title>Close</title><path d="M14.348 5.652a.5.5 0 0 1 .708.708l-8 8a.5.5 0 0 1-.708-.708l8-8zM5.652 5.652a.5.5 0 0 1 .708 0l8 8a.5.5 0 0 1-.708.708l-8-8z"/></svg>
</span>
</div>
<div x-cloak x-data="{ showError: @if(session('error')) true @else false @endif }" x-init="setTimeout(() => { showError = false; }, 5000)" x-show="showError" x-transition:enter="transition ease-out duration-300" x-transition:enter-start="opacity-0 transform scale-90" x-transition:enter-end="opacity-100 transform scale-100" x-transition:leave="transition ease-in duration-200" x-transition:leave-start="opacity-100 transform scale-100" x-transition:leave-end="opacity-0 transform scale-90" class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative mb-4" role="alert">
<strong class="font-bold">Error!</strong>
<span class="block sm:inline">{{ session('error') }}</span>
<span class="absolute top-0 bottom-0 right-0 px-4 py-3">
<svg x-on:click="showError = false" class="fill-current h-6 w-6 text-red-500" role="button" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><title>Close</title><path d="M14.348 5.652a.5.5 0 0 1 .708.708l-8 8a.5.5 0 0 1-.708-.708l8-8zM5.652 5.652a.5.5 0 0 1 .708 0l8 8a.5.5 0 0 1-.708.708l-8-8z"/></svg>
</span>
</div>

View File

@ -0,0 +1,74 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ config('app.name') }} | {{ $title }}</title>
@vite('resources/css/app.css')
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdn.datatables.net/2.0.7/css/dataTables.dataTables.css" />
<style>
[x-cloak] { display: none; }
</style>
</head>
<body class="min-h-screen flex flex-col" x-data="{ open: true }">
@include('layouts.partials.navbar')
<div class="flex flex-1 w-full">
@include('layouts.partials.sidebar')
<div class="flex-1 p-10 bg-sky-50">
<div class="text-[#6888E4] font-semibold text-2xl">
{{ $title }}
</div>
<div class="bg-white p-5 mt-5">
<div>
@include('components.flash')
</div>
@yield('content')
</div>
@yield('secondtable')
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.datatables.net/2.0.7/js/dataTables.js"></script>
<script src="{{ asset('assets/js/app.js')}}"></script>
@vite('resources/js/app.js')
@yield('script')
<script>
async function logout(event) {
event.preventDefault();
const confirmed = confirm("Are you sure you want to log out?");
if (!confirmed) {
return;
}
try {
const response = await fetch("{{ route('dashboard.logout') }}", {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
});
const data = await response.json();
if (response.ok) {
alert(data.message)
window.location.href = data.redirect;
} else {
alert(data.message);
}
} catch (error) {
alert('An error occurred: ' + error.message);
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,26 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ config('app.name') }} | {{ $title }}</title>
@vite('resources/css/app.css')
</head>
<body>
<div class="flex justify-center items-center bg-white">
<div class="w-full min-h-screen flex justify-between items-center mx-64">
<div class="w-1/2">
<img src="{{ asset('assets/images/hero.jpeg')}}" alt="" class="w-full">
</div>
<div class="w-1/2">
<div class="flex justify-center items-center">
@yield('content')
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
@vite('resources/js/app.js')
@yield('script')
</body>
</html>

View File

@ -0,0 +1,51 @@
<div class="bg-white flex justify-between items-center w-full">
<div class="max-w-[300px] flex justify-between items-center">
<img src="{{ asset('assets/images/logo.png')}}" alt="" class="w-20">
<div class="flex justify-center items-center font-bold text-sm text-[#6888E4]">
{{ env('APP_NAME')}}
</div>
</div>
<div class="p-10 flex justify-between items-center w-full">
<div x-on:click="open = ! open">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" />
</svg>
</div>
<div x-data="{ open: false }" class="relative">
<div class="flex justify-between items-center cursor-pointer" x-on:click="open = ! open">
<div>
@if (Auth::user()->photo)
<img src="{{asset('storage/'. Auth::user()->photo)}}" alt="" class="w-8 h-8 rounded-full">
@else
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
</svg>
@endif
</div>
<div class="mx-2">
{{ Auth::user()->name }}
</div>
<div>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-3 h-3">
<path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" />
</svg>
</div>
</div>
<div x-show="open" x-transition x-cloak class="fixed right-0 mr-10 p-2 w-[200px] shadow-lg bg-[#6888E4] rounded-lg mt-5">
<ul class="mx-2">
<a href="{{ route('profile.update')}}">
<li class="transition duration-300 p-2 hover:bg-gray-50 rounded-lg my-2 bg-white text-[#6888E4]">
Profile
</li>
</a>
<a href="#" onclick="logout(event)">
<li class="transition duration-300 p-2 hover:bg-red-600 rounded-lg my-2 bg-red-500 text-white">
Logout
</li>
</a>
</ul>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,82 @@
<div class="bg-[#4B70F5] min-w-[300px]"
x-show="open"
x-transition:enter="transition-transform ease-out duration-300 transform"
x-transition:enter-start="translate-x-[-300px]"
x-transition:enter-end="translate-x-0"
x-transition:leave="transition-transform ease-in duration-300 transform"
x-transition:leave-start="translate-x-0"
x-transition:leave-end="translate-x-[-300px]"
>
<ul class="p-10 text-[#dde5fa]">
<li>
<a href="{{ route('dashboard')}}" class="flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2">
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6A2.25 2.25 0 0 1 6 3.75h2.25A2.25 2.25 0 0 1 10.5 6v2.25a2.25 2.25 0 0 1-2.25 2.25H6a2.25 2.25 0 0 1-2.25-2.25V6ZM3.75 15.75A2.25 2.25 0 0 1 6 13.5h2.25a2.25 2.25 0 0 1 2.25 2.25V18a2.25 2.25 0 0 1-2.25 2.25H6A2.25 2.25 0 0 1 3.75 18v-2.25ZM13.5 6a2.25 2.25 0 0 1 2.25-2.25H18A2.25 2.25 0 0 1 20.25 6v2.25A2.25 2.25 0 0 1 18 10.5h-2.25a2.25 2.25 0 0 1-2.25-2.25V6ZM13.5 15.75a2.25 2.25 0 0 1 2.25-2.25H18a2.25 2.25 0 0 1 2.25 2.25V18A2.25 2.25 0 0 1 18 20.25h-2.25A2.25 2.25 0 0 1 13.5 18v-2.25Z" />
</svg>
Dashboard
</a>
</li>
<div class="border-b-2 my-5 opacity-50"></div>
<div class="font-bold text-[#a7b8ec] mb-3">
DATA PELANGGARAN
</div>
<li>
<a href="{{ route('pelanggaran')}}" class="flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12h3.75M9 15h3.75M9 18h3.75m3 .75H18a2.25 2.25 0 0 0 2.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 0 0-1.123-.08m-5.801 0c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75 2.25 2.25 0 0 0-.1-.664m-5.8 0A2.251 2.251 0 0 1 13.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m0 0H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V9.375c0-.621-.504-1.125-1.125-1.125H8.25ZM6.75 12h.008v.008H6.75V12Zm0 3h.008v.008H6.75V15Zm0 3h.008v.008H6.75V18Z" />
</svg>
Pelanggaran Siswa
</a>
</li>
<div class="border-b-2 my-5 opacity-50"></div>
<div class="font-bold text-[#a7b8ec] mb-3">
DATA MASTER
</div>
<li>
<a href="{{ route('siswa')}}" class="flex items-center my-3">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2">
<path stroke-linecap="round" stroke-linejoin="round" d="M15 19.128a9.38 9.38 0 0 0 2.625.372 9.337 9.337 0 0 0 4.121-.952 4.125 4.125 0 0 0-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 0 1 8.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0 1 11.964-3.07M12 6.375a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0Zm8.25 2.25a2.625 2.625 0 1 1-5.25 0 2.625 2.625 0 0 1 5.25 0Z" />
</svg>
Data Siswa
</a>
</li>
<li>
<a href="{{ route('jenispelanggaran')}}" class="flex items-center my-3">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 7.5V6.108c0-1.135.845-2.098 1.976-2.192.373-.03.748-.057 1.123-.08M15.75 18H18a2.25 2.25 0 0 0 2.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 0 0-1.123-.08M15.75 18.75v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5A3.375 3.375 0 0 0 6.375 7.5H5.25m11.9-3.664A2.251 2.251 0 0 0 15 2.25h-1.5a2.251 2.251 0 0 0-2.15 1.586m5.8 0c.065.21.1.433.1.664v.75h-6V4.5c0-.231.035-.454.1-.664M6.75 7.5H4.875c-.621 0-1.125.504-1.125 1.125v12c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V16.5a9 9 0 0 0-9-9Z" />
</svg>
Data Jenis Pelanggaran
</a>
</li>
<li>
<a href="{{ route('sanksi')}}" class="flex items-center my-3">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 7.5V6.108c0-1.135.845-2.098 1.976-2.192.373-.03.748-.057 1.123-.08M15.75 18H18a2.25 2.25 0 0 0 2.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 0 0-1.123-.08M15.75 18.75v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5A3.375 3.375 0 0 0 6.375 7.5H5.25m11.9-3.664A2.251 2.251 0 0 0 15 2.25h-1.5a2.251 2.251 0 0 0-2.15 1.586m5.8 0c.065.21.1.433.1.664v.75h-6V4.5c0-.231.035-.454.1-.664M6.75 7.5H4.875c-.621 0-1.125.504-1.125 1.125v12c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V16.5a9 9 0 0 0-9-9Z" />
</svg>
Data Sanksi
</a>
</li>
<li>
<a href="{{ route('tindakan')}}" class="flex items-center my-3">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 7.5V6.108c0-1.135.845-2.098 1.976-2.192.373-.03.748-.057 1.123-.08M15.75 18H18a2.25 2.25 0 0 0 2.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 0 0-1.123-.08M15.75 18.75v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5A3.375 3.375 0 0 0 6.375 7.5H5.25m11.9-3.664A2.251 2.251 0 0 0 15 2.25h-1.5a2.251 2.251 0 0 0-2.15 1.586m5.8 0c.065.21.1.433.1.664v.75h-6V4.5c0-.231.035-.454.1-.664M6.75 7.5H4.875c-.621 0-1.125.504-1.125 1.125v12c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V16.5a9 9 0 0 0-9-9Z" />
</svg>
Data Tindakan
</a>
</li>
@if (Auth::user()->usertype === 'admin')
<div class="border-b-2 my-5 opacity-50"></div>
<div class="font-bold text-[#a7b8ec] mb-3">
DATA PENGGUNA
</div>
<li>
<a href="{{ route('user')}}" class="flex items-center my-3">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-2">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z" />
</svg>
Pengguna
</a>
</li>
@endif
</ul>
</div>

View File

@ -0,0 +1,67 @@
@extends('layouts.auth')
@section('content')
<div class="block max-w-md mx-auto w-full">
<div class="font-bold text-4xl text-center mb-10">Sign In to Your Account</div>
<form id="login-form">
@csrf
<div class="py-5">
<label for="email" class="mb-2 block font-semibold">Email</label>
<input type="email" name="email" id="email" class="border rounded p-2 w-full" placeholder="Masukkan Email">
</div>
<div class="py-5">
<label for="password" class="mb-2 block font-semibold">Password</label>
<input type="password" name="password" id="password" class="border rounded p-2 w-full" placeholder="Masukkan Password">
</div>
<div class="py-5">
<button type="submit" class="bg-[#0056F8] text-white rounded p-2 w-full">Login</button>
</div>
<div class="flex justify-center items-center">
<span>
Dont have account?<a href="{{ route('register')}}" class="text-blue-500"> Create an account</a>
</span>
</div>
</form>
</div>
@endsection
@section('script')
<script>
async function submitLoginForm(event) {
event.preventDefault();
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
try {
const response = await fetch('{{ route('login') }}', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
body: JSON.stringify({
email: email,
password: password
})
});
const data = await response.json();
if (response.ok) {
alert(data.message);
window.location.href = data.redirect;
} else {
alert('Login failed: ' + data.message);
}
} catch (error) {
alert('An error occurred: ' + error.message);
}
}
document.getElementById('login-form').addEventListener('submit', submitLoginForm);
</script>
@endsection

View File

@ -0,0 +1,76 @@
@extends('layouts.auth')
@section('content')
<div class="block max-w-md mx-auto w-full">
<div class="font-bold text-4xl text-center mb-10">Create an Account</div>
<form id="register-form">
@csrf
<div class="py-5">
<label for="name" class="mb-2 block font-semibold">Name</label>
<input type="text" name="name" id="name" class="border rounded p-2 w-full" placeholder="Masukkan Nama">
</div>
<div class="py-5">
<label for="email" class="mb-2 block font-semibold">Email</label>
<input type="email" name="email" id="email" class="border rounded p-2 w-full" placeholder="Masukkan Email">
</div>
<div class="py-5">
<label for="phone" class="mb-2 block font-semibold">Phone</label>
<input type="number" name="phone" id="phone" class="border rounded p-2 w-full" placeholder="Masukkan No. HP">
</div>
<div class="py-5">
<label for="password" class="mb-2 block font-semibold">Password</label>
<input type="password" name="password" id="password" class="border rounded p-2 w-full" placeholder="Masukkan Password">
</div>
<div class="py-5">
<button type="submit" class="bg-[#0056F8] text-white rounded p-2 w-full">Register</button>
</div>
<div class="flex justify-center items-center">
<span>
Already have an account? <a href="{{ route('login') }}" class="text-blue-500">Sign in</a>
</span>
</div>
</form>
</div>
@endsection
@section('script')
<script>
async function submitRegisterForm(event) {
event.preventDefault();
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const phone = document.getElementById('phone').value;
const password = document.getElementById('password').value;
try {
const response = await fetch('{{ route('register') }}', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
body: JSON.stringify({
name: name,
email: email,
phone: phone,
password: password
})
});
const data = await response.json();
if (response.ok) {
alert(data.message);
window.location.href = data.redirect;
} else {
alert('Registration failed: ' + data.message);
}
} catch (error) {
alert('An error occurred: ' + error.message);
}
}
document.getElementById('register-form').addEventListener('submit', submitRegisterForm);
</script>
@endsection

View File

@ -0,0 +1,156 @@
@extends('layouts.app')
@section('content')
<div class="grid grid-cols-3 gap-5 mb-20">
<div class="flex justify-center items-center">
<div>
<div class="font-semibold py-5">
Siswa Yang Melakukan Pelanggaran
</div>
<div class="flex justify-items-start items-center">
<div class="rounded-full p-3 bg-[#FFECDF]">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="text-[#FF771D] w-8 h-8 ">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z" />
</svg>
</div>
<div class="ml-5 text-3xl font-semibold">
{{ $countPelanggar }}
</div>
</div>
</div>
</div>
<div class="flex justify-center items-center">
<div>
<div class="font-semibold py-5">
Jumlah Siswa
</div>
<div class="flex justify-items-start items-center">
<div class="rounded-full p-3 bg-gray-200">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="text-[#4154F1] w-8 h-8 ">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z" />
</svg>
</div>
<div class="ml-5 text-3xl font-semibold">
{{ $countSiswa }}
</div>
</div>
</div>
</div>
<div class="flex justify-center items-center">
<div>
<div class="font-semibold py-5">
Kriteria Pelanggaran
</div>
<div class="flex justify-items-start items-center">
<div class="rounded-full p-3 bg-[#FFECDF]">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="text-[#FF771D] w-8 h-8">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12h3.75M9 15h3.75M9 18h3.75m3 .75H18a2.25 2.25 0 0 0 2.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 0 0-1.123-.08m-5.801 0c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75 2.25 2.25 0 0 0-.1-.664m-5.8 0A2.251 2.251 0 0 1 13.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m0 0H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V9.375c0-.621-.504-1.125-1.125-1.125H8.25ZM6.75 12h.008v.008H6.75V12Zm0 3h.008v.008H6.75V15Zm0 3h.008v.008H6.75V18Z" />
</svg>
</div>
<div class="ml-5 text-3xl font-semibold">
{{ $countSubKriteria }}
</div>
</div>
</div>
</div>
</div>
{{-- <div class="flex items-center">
<div class="w-full">
<canvas id="donat"></canvas>
</div>
<div class="w-full">
<div class="container mx-auto px-4 py-8">
<div class="block">
<div class="flex items-center">
<div class="bg-[#95CE7A] text-center p-4 rounded-lg my-2 mr-10">
</div>
<p class="text-base font-semibold">Pelanggaran Ringan</p>
</div>
<div class="flex items-center">
<div class="bg-[#5470C6] text-center p-4 rounded-lg my-2 mr-10">
</div>
<p class="text-base font-semibold">Pelanggaran Sedang</p>
</div>
<div class="flex items-center">
<div class="bg-[#FAC858] text-center p-4 rounded-lg my-2 mr-10">
</div>
<p class="text-base font-semibold">Tindak Pidana Ringan (TIPIRING)</p>
</div>
<div class="flex items-center">
<div class="bg-[#EE6666] text-center p-4 rounded-lg my-2 mr-10">
</div>
<p class="text-base font-semibold">Tindak Pidana Berat (TIPIRAT)</p>
</div>
</div>
</div>
</div>
</div> --}}
<div class="flex">
<div class="w-1/2">
<canvas id="donat"></canvas>
</div>
<div class="w-1/2">
<table class="table-auto border-collapse border-2 border-gray-600 w-full">
<thead>
<tr class="bg-[#5A72A0]">
<th class="border-2 border-gray-600 px-4 py-2" >Range Nilai</th>
<th class="border-2 border-gray-600 px-4 py-2" >Keterangan</th>
</tr>
</thead>
<tbody>
<tr>
<td class="border-2 border-gray-600 px-4 py-2">1 - 2</td>
<td class="border-2 border-gray-600 px-4 py-2">Pelanggaran Ringan</td>
</tr>
<tr>
<td class="border-2 border-gray-600 px-4 py-2">2.1 - 8</td>
<td class="border-2 border-gray-600 px-4 py-2">Pelanggaran Sedang</td>
</tr>
<tr>
<td class="border-2 border-gray-600 px-4 py-2">8.1 - 20</td>
<td class="border-2 border-gray-600 px-4 py-2">Tindak Pidana Ringan (TIPIRING)</td>
</tr>
<tr>
<td class="border-2 border-gray-600 px-4 py-2">20.1 - 100</td>
<td class="border-2 border-gray-600 px-4 py-2">Tindak Pidana Berat (TIPIRAT)</td>
</tr>
</tbody>
</table>
</div>
</div>
@endsection
@section('script')
<script>
document.addEventListener('DOMContentLoaded', function() {
const data = @json($data);
const ctx = document.getElementById('donat').getContext('2d');
const myChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: data.map(row => row.label),
datasets: [
{
label: 'Tingkat',
data: data.map(row => row.value),
backgroundColor: ['#95CE7A', '#5470C6', '#FAC858', '#EE6666'],
hoverBackgroundColor: ['#95CE7A', '#5470C6', '#FAC858', '#EE6666']
}
]
},
options: {
responsive: true,
maintainAspectRatio: false
}
});
});
</script>
@endsection

View File

@ -0,0 +1,36 @@
@extends('layouts.app')
@section('content')
<form class="w-1/2" action="{{ route('jenispelanggaran.create') }}" method="POST">
@csrf
<div class="py-5">
<label for="kode_kriteria" class="mb-2 block font-semibold">Kode Kriteria</label>
<select name="kode_kriteria" id="kode_kriteria" class="border rounded p-2 w-full">
<option value="">Pilih Kode Kriteria</option>
@foreach($kriteria as $item)
<option value="{{ $item->kode }}">{{ $item->kode }} - {{$item->kriteria}}</option>
@endforeach
</select>
@if($errors->has('kode_kriteria'))
<span class="text-red-500">{{ $errors->first('kode_kriteria') }}</span>
@endif
</div>
<div class="py-5">
<label for="jenis_pelanggaran" class="mb-2 block font-semibold">Jenis Pelanggaran</label>
<input type="text" name="jenis_pelanggaran" id="jenis_pelanggaran" class="border rounded p-2 w-full" placeholder="Masukkan Jenis Pelanggaran" value="{{ old('jenis_pelanggaran') }}">
@if($errors->has('jenis_pelanggaran'))
<span class="text-red-500">{{ $errors->first('jenis_pelanggaran') }}</span>
@endif
</div>
<div class="py-5">
<label for="point" class="mb-2 block font-semibold">Point</label>
<input type="number" name="point" id="point" class="border rounded p-2 w-full" placeholder="Masukkan Point" value="{{ old('point') }}">
@if($errors->has('point'))
<span class="text-red-500">{{ $errors->first('point') }}</span>
@endif
</div>
<button type="submit" class="bg-green-500 text-white rounded p-2 w-fit px-10">Simpan</button>
</form>
@endsection

View File

@ -0,0 +1,131 @@
@extends('layouts.app')
@section('content')
<div class="mb-10 flex justify-end items-center">
@if (Auth::user()->usertype === 'admin')
<a href="{{route('kriteriapelanggaran.create')}}"
class="rounded text-white py-2 px-3 flex items-center {{ $totalBobot >= 100 ? 'bg-gray-400 cursor-not-allowed' : '' }}" style="{{ $totalBobot < 100 ? 'background-color: #1679AB;' : '' }}"
{{ $totalBobot >= 100 ? 'aria-disabled="true"' : '' }}>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-3">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
</svg>
Tambah Data
</a>
@endif
</div>
@if($totalBobot != 100)
<div class="mb-10 p-4 bg-yellow-200 text-yellow-800 rounded animate-pulse">
Peringatan: Total Persentase Bobot adalah {{ $totalBobot }}%. Total harus tepat 100%.
</div>
@endif
<table id="kriteria" class="display w-full">
<thead>
<tr>
<th>No</th>
<th>Kode</th>
<th>Kriteria</th>
<th>Persentasi Bobot</th>
@if (Auth::user()->usertype === 'admin')
<th>Action</th>
@endif
</tr>
</thead>
<tbody>
@foreach ($kriteria as $index => $kriteriapelanggaran )
<tr>
<td>{{ $index + 1 }}</td>
<td>{{ $kriteriapelanggaran->kode }}</td>
<td>{{ $kriteriapelanggaran->kriteria }}</td>
<td>{{ $kriteriapelanggaran->bobot }}%</td>
@if (Auth::user()->usertype === 'admin')
<td class="flex text-white">
<a href="{{ route('kriteriapelanggaran.update', $kriteriapelanggaran->id)}}" class="bg-yellow-500 rounded-lg p-2 mr-3">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" />
</svg>
</a>
<a href="{{ route('kriteriapelanggaran.delete', $kriteriapelanggaran->id)}}" class="bg-red-500 rounded-lg p-2" onclick="return confirmDelete()">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
</svg>
</a>
</td>
@endif
</tr>
@endforeach
</tbody>
</table>
@endsection
@section('secondtable')
<div class="text-[#6888E4] font-semibold text-2xl mt-10">
Jenis Pelanggaran
</div>
<div class="bg-white p-5 mt-5">
<div class="mb-10 flex justify-end items-center">
@if (Auth::user()->usertype === 'admin')
<a href="{{route('jenispelanggaran.create')}}" class="rounded text-white py-2 px-3 flex items-center" style="background-color: #1679AB;">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-3">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
</svg>
Tambah Data
</a>
@endif
</div>
<table id="jenis" class="display w-full">
<thead>
<tr>
<th>No</th>
<th>Kode Kriteria</th>
<th>Jenis Pelanggaran</th>
<th>Point</th>
@if (Auth::user()->usertype === 'admin')
<th>Action</th>
@endif
</tr>
</thead>
<tbody>
@foreach ($jenis as $index => $jenispelanggaran )
<tr>
<td>{{ $index + 1 }}</td>
<td>{{ $jenispelanggaran->kode_kriteria }}</td>
<td>{{ $jenispelanggaran->jenis_pelanggaran }}</td>
<td>{{ $jenispelanggaran->point }}</td>
@if (Auth::user()->usertype === 'admin')
<td class="flex text-white">
<a href="{{ route('jenispelanggaran.update', $jenispelanggaran->id)}}" class="bg-yellow-500 rounded-lg p-2 mr-3">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" />
</svg>
</a>
<a href="{{ route('jenispelanggaran.delete', $jenispelanggaran->id)}}" class="bg-red-500 rounded-lg p-2" onclick="return confirmDelete()">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
</svg>
</a>
</td>
@endif
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection
@section('script')
<script>
$(document).ready(function() {
$('#jenis').DataTable();
$('#kriteria').DataTable();
});
</script>
@endsection

View File

@ -0,0 +1,36 @@
@extends('layouts.app')
@section('content')
<form class="w-1/2" action="{{ route('jenispelanggaran.update', $data->id) }}" method="POST">
@csrf
<div class="py-5">
<label for="kode_kriteria" class="mb-2 block font-semibold">Kode Kriteria</label>
<select name="kode_kriteria" id="kode_kriteria" class="border rounded p-2 w-full">
<option value="">Pilih Kode Kriteria</option>
@foreach($kriteria as $item)
<option value="{{ $item->kode }}" {{ $item->kode == $data->kode_kriteria ? 'selected' : '' }}>{{ $item->kode }}</option>
@endforeach
</select>
@if($errors->has('kode_kriteria'))
<span class="text-red-500">{{ $errors->first('kode_kriteria') }}</span>
@endif
</div>
<div class="py-5">
<label for="jenis_pelanggaran" class="mb-2 block font-semibold">Jenis Pelanggaran</label>
<input type="text" name="jenis_pelanggaran" id="jenis_pelanggaran" class="border rounded p-2 w-full" placeholder="Masukkan Jenis Pelanggaran" value="{{ $data->jenis_pelanggaran }}">
@if($errors->has('jenis_pelanggaran'))
<span class="text-red-500">{{ $errors->first('jenis_pelanggaran') }}</span>
@endif
</div>
<div class="py-5">
<label for="point" class="mb-2 block font-semibold">Point</label>
<input type="number" name="point" id="point" class="border rounded p-2 w-full" placeholder="Masukkan Point" value="{{ $data->point }}">
@if($errors->has('point'))
<span class="text-red-500">{{ $errors->first('point') }}</span>
@endif
</div>
<button type="submit" class="bg-green-500 text-white rounded p-2 w-fit px-10">Simpan</button>
</form>
@endsection

View File

@ -0,0 +1,30 @@
@extends('layouts.app')
@section('content')
<form class="w-1/2" action="{{ route('kriteriapelanggaran.create') }}" method="POST">
@csrf
<div class="py-5">
<label for="kriteria" class="mb-2 block font-semibold">Kriteria</label>
<input type="text" name="kriteria" id="kriteria" class="border rounded p-2 w-full" placeholder="Masukkan Kriteria" value="{{ old('kriteria') }}">
@if($errors->has('kriteria'))
<span class="text-red-500">{{ $errors->first('kriteria') }}</span>
@endif
</div>
<div class="py-5">
<label for="bobot" class="mb-2 block font-semibold">Bobot</label>
@php
$currentTotalBobot = App\Models\KriteriaPelanggaran::sum('bobot');
$remainingBobot = 100 - $currentTotalBobot;
$suggestedBobot = min($remainingBobot, old('bobot', $remainingBobot)); // Calculate suggested bobot
@endphp
<input type="number" name="bobot" id="bobot" class="border rounded p-2 w-full" placeholder="Masukkan Bobot" value="{{ $suggestedBobot }}" max="{{ $remainingBobot }}">
@if($errors->has('bobot'))
<span class="text-red-500">{{ $errors->first('bobot') }}</span>
@endif
<span class="text-red-500 animate-pulse">Saran: {{ $suggestedBobot }}%</span>
</div>
<button type="submit" class="bg-green-500 text-white rounded p-2 w-fit px-10">Simpan</button>
</form>
@endsection

View File

@ -0,0 +1,24 @@
@extends('layouts.app')
@section('content')
<form class="w-1/2" action="{{ route('kriteriapelanggaran.update', $data->id) }}" method="POST">
@csrf
<div class="py-5">
<label for="kriteria" class="mb-2 block font-semibold">Kriteria</label>
<input type="text" name="kriteria" id="kriteria" class="border rounded p-2 w-full" placeholder="Masukkan Kriteria" value="{{ $data->kriteria }}"> <!-- Use $data->kriteria to fill the input -->
@if($errors->has('kriteria'))
<span class="text-red-500">{{ $errors->first('kriteria') }}</span>
@endif
</div>
<div class="py-5">
<label for="bobot" class="mb-2 block font-semibold">Bobot</label>
<input type="number" name="bobot" id="bobot" class="border rounded p-2 w-full" placeholder="Masukkan Bobot" value="{{ $data->bobot }}" max="100"> <!-- Use $data->bobot to fill the input -->
@if($errors->has('bobot'))
<span class="text-red-500">{{ $errors->first('bobot') }}</span>
@endif
</div>
<button type="submit" class="bg-green-500 text-white rounded p-2 w-fit px-10">Simpan</button>
</form>
@endsection

View File

@ -0,0 +1,197 @@
@extends('layouts.app')
@section('content')
<form class="w-full" action="{{ route('pelanggaran.create') }}" method="POST">
@csrf
<div class="py-5">
<label for="siswa" class="mb-2 block font-semibold">Siswa</label>
<select name="id_siswa" id="id_siswa" class="border rounded p-2 w-full js-example-basic-single">
<option value="" disabled selected>Masukkan Siswa</option>
@foreach ($siswa as $option)
<option value="{{ $option->id }}" {{ old('id_siswa') == $option->id ? 'selected' : '' }}>
{{ $option->nama }}
</option>
@endforeach
</select>
@if($errors->has('id_siswa'))
<span class="text-red-500">{{ $errors->first('id_siswa') }}</span>
@endif
</div>
<div id="message" class="py-5 text-gray-500">Klik "Tambah Baris" untuk memulai.</div>
<button type="button" id="addRowButton" onclick="addRow()" class="bg-sky-500 text-white rounded p-2 w-fit px-10">Tambah Baris</button>
<table class="w-full border-collapse border-spacing-4 my-5">
<thead>
<tr>
<th class="border py-2 px-4">Kriteria</th>
<th class="border py-2 px-4">Jenis Pelanggaran</th>
<th class="border py-2 w-fit"></th>
</tr>
</thead>
<tbody id="dynamicRows">
</tbody>
</table>
<button type="submit" class="bg-green-500 text-white rounded p-2 w-fit px-10">Simpan</button>
</form>
@endsection
@section('script')
<script>
$(document).ready(function() {
$('.js-example-basic-single').select2();
});
// Embed the kriteria_pelanggaran data as JSON objects
var kriteriaPelanggaran = @json($kriteria_pelanggaran);
// Function to add a new row
function addRow() {
var dynamicRows = document.getElementById('dynamicRows');
var message = document.getElementById('message');
// Hide the message when a row is added
if (message) {
message.style.display = 'none';
}
var newRow = document.createElement('tr');
// Create the first select cell for criteria
var firstSelectCell = document.createElement('td');
firstSelectCell.classList.add('border', 'py-2', 'px-4');
var firstSelect = document.createElement('select');
firstSelect.setAttribute('name', 'id_kriteria[]');
firstSelect.classList.add('border', 'rounded', 'p-2', 'w-full');
var firstOption = document.createElement('option');
firstOption.setAttribute('value', '');
firstOption.setAttribute('disabled', 'disabled');
firstOption.setAttribute('selected', 'selected');
firstOption.innerText = 'Masukkan Kriteria';
firstSelect.appendChild(firstOption);
// Populate the options for the first select
kriteriaPelanggaran.forEach(function(option) {
var opt = document.createElement('option');
opt.value = option.id;
opt.innerText = option.kriteria;
firstSelect.appendChild(opt);
});
firstSelectCell.appendChild(firstSelect);
newRow.appendChild(firstSelectCell);
// Create the second select cell for jenis pelanggaran
var secondSelectCell = document.createElement('td');
secondSelectCell.classList.add('border', 'py-2', 'px-4');
var secondSelect = document.createElement('select');
secondSelect.setAttribute('name', 'id_jenis[]');
secondSelect.classList.add('border', 'rounded', 'p-2', 'w-full');
var secondOption = document.createElement('option');
secondOption.setAttribute('value', '');
secondOption.setAttribute('disabled', 'disabled');
secondOption.setAttribute('selected', 'selected');
secondOption.innerText = 'Pilih Jenis Pelanggaran';
secondSelect.appendChild(secondOption);
secondSelectCell.appendChild(secondSelect);
newRow.appendChild(secondSelectCell);
// Add event listener to the first select
firstSelect.addEventListener('change', function() {
updateJenisPelanggaranOptions(firstSelect, secondSelect);
updateKriteriaOptions();
});
// Create the delete button cell
var deleteButtonCell = document.createElement('td');
deleteButtonCell.classList.add('border', 'py-2', 'px-4');
var deleteButton = document.createElement('button');
deleteButton.setAttribute('type', 'button');
deleteButton.setAttribute('onclick', 'removeRow(this)');
deleteButton.classList.add('bg-red-500', 'text-white', 'rounded', 'p-2');
deleteButton.innerText = 'Delete';
deleteButtonCell.appendChild(deleteButton);
newRow.appendChild(deleteButtonCell);
// Append the new row to the table
dynamicRows.appendChild(newRow);
// Update options for kriteria select elements
updateKriteriaOptions();
}
// Function to update the jenis_pelanggaran options based on selected kriteria
function updateJenisPelanggaranOptions(kriteriaSelect, jenisSelect) {
if (!kriteriaSelect || !jenisSelect) {
console.error('Missing select elements');
return;
}
// Get the selected kriteria id
var selectedKriteriaId = kriteriaSelect.value;
// Clear previous options in the jenis select
jenisSelect.innerHTML = '';
// Add the default option
var defaultOption = document.createElement('option');
defaultOption.setAttribute('value', '');
defaultOption.setAttribute('disabled', 'disabled');
defaultOption.setAttribute('selected', 'selected');
defaultOption.innerText = 'Pilih Jenis Pelanggaran';
jenisSelect.appendChild(defaultOption);
// Find the corresponding kriteria object
var selectedKriteria = kriteriaPelanggaran.find(function(kriteria) {
return kriteria.id == selectedKriteriaId;
});
// Add the new options based on selected kriteria
if (selectedKriteria && selectedKriteria.jenis) {
selectedKriteria.jenis.forEach(function(option) {
var opt = document.createElement('option');
opt.value = option.id;
opt.innerText = option.jenis_pelanggaran;
jenisSelect.appendChild(opt);
});
} else {
console.error('No jenis pelanggaran found for the selected kriteria');
}
}
// Function to update the kriteria options to prevent duplicates
function updateKriteriaOptions() {
var kriteriaSelects = document.querySelectorAll('select[name="id_kriteria[]"]');
var selectedKriteriaIds = Array.from(kriteriaSelects).map(function(select) {
return select.value;
});
}
// Function to remove a row
function removeRow(btn) {
var row = btn.parentNode.parentNode;
if (row) {
row.parentNode.removeChild(row);
} else {
console.error('Row not found for the delete button');
}
// If no rows left, show the message again
var dynamicRows = document.getElementById('dynamicRows');
if (dynamicRows.children.length === 0) {
var message = document.getElementById('message');
if (message) {
message.style.display = 'block';
}
}
// Update options for kriteria select elements
updateKriteriaOptions();
}
</script>
@endsection

View File

@ -0,0 +1,223 @@
{{-- @extends('layouts.app')
@section('content')
<div class="container mx-auto" id="printThis">
<div class="text-left mb-6 px-4 flex justify-between items-center">
<div class="text-2xl font-bold">
Detail Pelanggaran
</div>
<button id="printButton" class="bg-blue-500 text-white py-2 px-4 rounded">
Print
</button>
</div>
<div class="mb-4 px-4 text-left">
<p class="py-2">Nama : {{ $data->siswa->nama }}</p>
<p class="py-2">NIS : {{ $data->siswa->nis }}</p>
<p class="py-2">Kelas : {{ $data->siswa->kelas }}</p>
</div>
<div class="text-left flex">
<table class="w-full bg-white">
<thead>
<tr>
<th class="py-2 px-4 border-b">No.</th>
<th class="py-2 px-4 border-b">Pelanggaran</th>
<th class="py-2 px-4 border-b">Poin</th>
<th class="py-2 px-4 border-b">Utility</th>
</tr>
</thead>
<tbody>
@php
$totalSmart = 0;
$rowCount = count($list);
@endphp
@foreach ($list as $index => $item)
@php
$utility = $item->kriteria->bobot / 100 * $item->jenis->point;
$totalSmart += $utility;
@endphp
<tr>
<td class="py-5 px-4 text-sky-500">{{ $index + 1 }}</td>
<td class="py-5 px-4">{{ $item->jenis->jenis_pelanggaran }}</td>
<td class="py-5 px-4">{{ $item->jenis->point }}</td>
<td class="py-5 px-4">{{ $utility }}</td>
</tr>
@endforeach
</tbody>
</table>
<table class="w-1/2">
<thead>
<tr>
<th class="py-2 px-4 border-b">Nilai SMART</th>
<th class="py-2 px-4 border-b">Tindakan</th>
<th class="py-2 px-4 border-b">Sanksi</th>
</tr>
</thead>
<tbody>
<tr>
<td class="py-5 px-4">{{ $totalSmart }}</td>
<td class="py-5 px-4">{{ $data->tindakan->tindakan_sekolah }}</td>
<td class="py-5 px-4">{{ $data->sanksi->jenis_sanksi }}</td>
</tr>
</tbody>
</table>
</div>
</div>
<script>
document.getElementById('printButton').addEventListener('click', function() {
var printContents = document.getElementById('printThis').innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
location.reload();
});
</script>
@endsection --}}
{{-- @extends('layouts.app')
@section('content')
<div class="container mx-auto" id="printThis">
<div class="text-left mb-6 px-4 flex justify-between items-center">
<div class="text-2xl font-bold">
Detail Pelanggaran
</div>
<button id="printButton" class="bg-blue-500 text-white py-2 px-4 rounded">
Print
</button>
</div>
<div class="mb-4 px-4 text-left">
<p class="py-2">Nama : {{ $data->siswa->nama }}</p>
<p class="py-2">NIS : {{ $data->siswa->nis }}</p>
<p class="py-2">Kelas : {{ $data->siswa->kelas }}</p>
</div>
<div class="text-left">
<table class="w-full bg-white table-auto border-collapse">
<thead>
<tr class="border-b">
<th class="py-2 px-4">No.</th>
<th class="py-2 px-4">Pelanggaran</th>
<th class="py-2 px-4">Poin</th>
<th class="py-2 px-4">Utility</th>
<th class="py-2 px-4">Nilai SMART</th>
<th class="py-2 px-4">Tindakan</th>
<th class="py-2 px-4">Sanksi</th>
</tr>
</thead>
<tbody>
@php
$totalSmart = 0;
$rowCount = count($list);
@endphp
@foreach ($list as $index => $item)
@php
$utility = $item->kriteria->bobot / 100 * $item->jenis->point;
$totalSmart += $utility;
@endphp
<tr>
<td class="py-5 px-4 text-sky-500">{{ $index + 1 }}</td>
<td class="py-5 px-4">{{ $item->jenis->jenis_pelanggaran }}</td>
<td class="py-5 px-4">{{ $item->jenis->point }}</td>
<td class="py-5 px-4">{{ $utility }}</td>
@if ($index === 0)
<td class="py-5 px-4" rowspan="{{ $rowCount }}">{{ $totalSmart }}</td>
<td class="py-5 px-4" rowspan="{{ $rowCount }}">{{ $data->tindakan->tindakan_sekolah }}</td>
<td class="py-5 px-4" rowspan="{{ $rowCount }}">{{ $data->sanksi->jenis_sanksi }}</td>
@endif
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<script>
document.getElementById('printButton').addEventListener('click', function() {
var printContents = document.getElementById('printThis').innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
location.reload();
});
</script>
@endsection --}}
@extends('layouts.app')
@section('content')
<div class="container mx-auto" id="printThis">
<div class="text-left mb-6 px-4 flex justify-between items-center">
<div class="text-2xl font-bold">
Detail Pelanggaran
</div>
<button id="printButton" class="bg-blue-500 text-white py-2 px-4 rounded">
Print
</button>
</div>
<div class="mb-4 px-4 text-left">
<p class="py-2">Nama : {{ $data->siswa->nama }}</p>
<p class="py-2">NIS : {{ $data->siswa->nis }}</p>
<p class="py-2">Kelas : {{ $data->siswa->kelas }}</p>
</div>
<div class="text-left">
<table class="w-full bg-white table-auto border-collapse">
<thead>
<tr class="border-b">
<th class="py-2 px-4">No.</th>
<th class="py-2 px-4">Pelanggaran</th>
<th class="py-2 px-4">Poin</th>
<th class="py-2 px-4">nilai ter-normalisasi</th>
<th class="py-2 px-4">Nilai SMART</th>
<th class="py-2 px-4">Tindakan</th>
<th class="py-2 px-4">Sanksi</th>
</tr>
</thead>
<tbody>
@php
$totalUtility = 0;
$totalSmart = 0;
$rowCount = count($list);
@endphp
@foreach ($list as $index => $item)
@php
$utility = $item->kriteria->bobot / 100 * $item->jenis->point;
$totalUtility += $utility;
@endphp
<tr>
<td class="py-5 px-4 text-sky-500">{{ $index + 1 }}</td>
<td class="py-5 px-4">{{ $item->jenis->jenis_pelanggaran }}</td>
<td class="py-5 px-4">{{ $item->jenis->point }}</td>
<td class="py-5 px-4">{{ $utility }}</td>
@if ($index === $rowCount - 1)
<td class="py-5 px-4">{{ $totalUtility }}</td>
<td class="py-5 px-4">{{ $data->tindakan->tindakan_sekolah }}</td>
<td class="py-5 px-4">{{ $data->sanksi->jenis_sanksi }}</td>
@endif
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<script>
document.getElementById('printButton').addEventListener('click', function() {
var printContents = document.getElementById('printThis').innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
location.reload();
});
</script>
@endsection

View File

@ -0,0 +1,79 @@
@extends('layouts.app')
@section('content')
<div class="mb-10 flex justify-end items-center">
<a href="{{route('pelanggaran.create')}}" class="rounded text-white py-2 px-3 flex items-center" style="background-color: #1679AB;">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-3">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
</svg>
Tambah Data
</a>
</div>
<table id="table" class="display w-full">
<thead>
<tr>
<th>No</th>
<th>Nama</th>
<th>NIS</th>
<th>Kelas</th>
<th>Wali Kelas</th>
<th>Tanggal</th>
<th>Nilai Smart</th>
<th>Tindakan</th>
<th>Sanksi</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach ($data as $index => $pelanggaran )
@php
$sum = 0;
foreach ($pelanggaran->listPelanggaran as $item) {
$sum += ($item->jenis->point) * ($item->kriteria->bobot / 100);
}
@endphp
<tr>
<td>{{ $index + 1 }}</td>
<td>{{ $pelanggaran->siswa->nama }}</td>
<td>{{ $pelanggaran->siswa->nis }}</td>
<td>{{ $pelanggaran->siswa->kelas }}</td>
<td>{{ $pelanggaran->siswa->walikelas->name}}</td>
<td>{{ $pelanggaran->updated_at }}</td>
<td>{{ $sum }}</td>
<td>{{ $pelanggaran->tindakan->tindakan_sekolah }}</td>
<td>{{ $pelanggaran->sanksi->jenis_sanksi}}</td>
<td class="flex text-white">
<a href="{{ route('pelanggaran.detail', $pelanggaran->id)}}" class="bg-green-500 rounded-lg p-2 mr-3">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" />
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
</svg>
</a>
<a href="{{ route('pelanggaran.update', $pelanggaran->id)}}" class="bg-yellow-500 rounded-lg p-2 mr-3">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" />
</svg>
</a>
<a href="{{ route('pelanggaran.delete', $pelanggaran->id)}}" class="bg-red-500 rounded-lg p-2" onclick="return confirmDelete()">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
</svg>
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
@endsection
@section('script')
<script>
$(document).ready(function() {
$('#table').DataTable();
});
</script>
@endsection

View File

@ -0,0 +1,197 @@
@extends('layouts.app')
@section('content')
<form class="w-full" action="{{ route('pelanggaran.update', ['id' => $pelanggaran->id]) }}" method="POST">
@csrf
<div class="py-5">
<label for="siswa" class="mb-2 block font-semibold">Siswa</label>
<select name="id_siswa" id="id_siswa" class="border rounded p-2 w-full js-example-basic-single">
<option value="" disabled selected>Masukkan Siswa</option>
@foreach ($siswa as $option)
<option value="{{ $option->id }}" {{ old('id_siswa', $pelanggaran->id_siswa) == $option->id ? 'selected' : '' }}>
{{ $option->nama }}
</option>
@endforeach
</select>
@if($errors->has('id_siswa'))
<span class="text-red-500">{{ $errors->first('id_siswa') }}</span>
@endif
</div>
<div id="message" class="py-5 text-gray-500">Klik "Tambah Baris" untuk memulai.</div>
<button type="button" id="addRowButton" onclick="addRow()" class="bg-sky-500 text-white rounded p-2 w-fit px-10">Tambah Baris</button>
<table class="w-full border-collapse border-spacing-4 my-5">
<thead>
<tr>
<th class="border py-2 px-4">Kriteria</th>
<th class="border py-2 px-4">Jenis Pelanggaran</th>
<th class="border py-2 w-fit"></th>
</tr>
</thead>
<tbody id="dynamicRows">
<!-- Populate existing data if available -->
@foreach ($pelanggaran->listPelanggaran as $list)
<tr>
<td class="border py-2 px-4">
<select name="id_kriteria[]" class="border rounded p-2 w-full" onchange="updateJenisPelanggaranOptions(this, this.parentNode.nextElementSibling.children[0])">
<option value="" disabled selected>Masukkan Kriteria</option>
@foreach ($kriteria_pelanggaran as $option)
<option value="{{ $option->id }}" {{ old('id_kriteria', $list->id_kriteria) == $option->id ? 'selected' : '' }}>
{{ $option->kriteria }}
</option>
@endforeach
</select>
</td>
<td class="border py-2 px-4">
<select name="id_jenis[]" class="border rounded p-2 w-full">
<option value="" disabled selected>Pilih Jenis Pelanggaran</option>
@foreach ($kriteria_pelanggaran->find($list->id_kriteria)->jenis as $jenis)
<option value="{{ $jenis->id }}" {{ old('id_jenis', $list->id_jenis) == $jenis->id ? 'selected' : '' }}>
{{ $jenis->jenis_pelanggaran }}
</option>
@endforeach
</select>
</td>
<td class="border py-2 px-4">
<button type="button" onclick="removeRow(this)" class="bg-red-500 text-white rounded p-2">Hapus</button>
</td>
</tr>
@endforeach
</tbody>
</table>
<button type="submit" class="bg-blue-500 text-white rounded p-2 w-fit px-10">Perbarui</button> <!-- Change button label -->
</form>
@endsection
@section('script')
<script>
$(document).ready(function() {
$('.js-example-basic-single').select2();
});
var kriteriaPelanggaran = @json($kriteria_pelanggaran);
function addRow() {
var dynamicRows = document.getElementById('dynamicRows');
var message = document.getElementById('message');
if (message) {
message.style.display = 'none';
}
var newRow = document.createElement('tr');
var firstSelectCell = document.createElement('td');
firstSelectCell.classList.add('border', 'py-2', 'px-4');
var firstSelect = document.createElement('select');
firstSelect.setAttribute('name', 'id_kriteria[]');
firstSelect.classList.add('border', 'rounded', 'p-2', 'w-full');
var firstOption = document.createElement('option');
firstOption.setAttribute('value', '');
firstOption.setAttribute('disabled', 'disabled');
firstOption.setAttribute('selected', 'selected');
firstOption.innerText = 'Masukkan Kriteria';
firstSelect.appendChild(firstOption);
kriteriaPelanggaran.forEach(function(option) {
var opt = document.createElement('option');
opt.value = option.id;
opt.innerText = option.kriteria;
firstSelect.appendChild(opt);
});
firstSelectCell.appendChild(firstSelect);
newRow.appendChild(firstSelectCell);
var secondSelectCell = document.createElement('td');
secondSelectCell.classList.add('border', 'py-2', 'px-4');
var secondSelect = document.createElement('select');
secondSelect.setAttribute('name', 'id_jenis[]');
secondSelect.classList.add('border', 'rounded', 'p-2', 'w-full');
var secondOption = document.createElement('option');
secondOption.setAttribute('value', '');
secondOption.setAttribute('disabled', 'disabled');
secondOption.setAttribute('selected', 'selected');
secondOption.innerText = 'Pilih Jenis Pelanggaran';
secondSelect.appendChild(secondOption);
secondSelectCell.appendChild(secondSelect);
newRow.appendChild(secondSelectCell);
firstSelect.addEventListener('change', function() {
updateJenisPelanggaranOptions(firstSelect, secondSelect);
updateKriteriaOptions();
});
var deleteButtonCell = document.createElement('td');
deleteButtonCell.classList.add('border', 'py-2', 'px-4');
var deleteButton = document.createElement('button');
deleteButton.setAttribute('type', 'button');
deleteButton.setAttribute('onclick', 'removeRow(this)');
deleteButton.classList.add('bg-red-500', 'text-white', 'rounded', 'p-2');
deleteButton.innerText = 'Delete';
deleteButtonCell.appendChild(deleteButton);
newRow.appendChild(deleteButtonCell);
dynamicRows.appendChild(newRow);
updateKriteriaOptions();
}
function updateJenisPelanggaranOptions(kriteriaSelect, jenisSelect) {
if (!kriteriaSelect || !jenisSelect) {
console.error('Missing select elements');
return;
}
var selectedKriteriaId = kriteriaSelect.value;
jenisSelect.innerHTML = '';
var defaultOption = document.createElement('option');
defaultOption.setAttribute('value', '');
defaultOption.setAttribute('disabled', 'disabled');
defaultOption.setAttribute('selected', 'selected');
defaultOption.innerText = 'Pilih Jenis Pelanggaran';
jenisSelect.appendChild(defaultOption);
var selectedKriteria = kriteriaPelanggaran.find(function(kriteria) {
return kriteria.id == selectedKriteriaId;
});
if (selectedKriteria && selectedKriteria.jenis) {
selectedKriteria.jenis.forEach(function(option) {
var opt = document.createElement('option');
opt.value = option.id;
opt.innerText = option.jenis_pelanggaran;
jenisSelect.appendChild(opt);
});
} else {
console.error('No jenis pelanggaran found for the selected kriteria');
}
}
function removeRow(btn) {
var row = btn.parentNode.parentNode;
if (row) {
row.parentNode.removeChild(row);
} else {
console.error('Row not found for the delete button');
}
var dynamicRows = document.getElementById('dynamicRows');
if (dynamicRows.children.length === 0) {
var message = document.getElementById('message');
if (message) {
message.style.display = 'block';
}
}
}
</script>
@endsection

View File

@ -0,0 +1,97 @@
@extends('layouts.app')
@section('content')
<div class="block mt-5" x-data="{ open: 'profile' }">
<div class="bg-white rounded-lg w-[400px] min-h-[200px]">
@if (Auth::user()->photo)
<div class="flex justify-center items-center min-h-[200px]">
<img src="{{ asset('storage/' . Auth::user()->photo)}}" alt="User Photo" class="rounded-full w-32 h-32 object-cover shadow-xl">
</div>
@else
<div class="flex justify-center items-center min-h-[200px]">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-32 h-32">
<path stroke-linecap="round" stroke-linejoin="round" d="M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
</svg>
</div>
@endif
</div>
<div class="bg-white w-full rounded-lg min-h-fit mt-5 p-5">
<div class="flex gap-10">
<div @click="open = 'profile'" :class="{ 'text-blue-500': open === 'profile' }" class="cursor-pointer">
Edit Profile
</div>
<div @click="open = 'password'" :class="{ 'text-blue-500': open === 'password' }" class="cursor-pointer">
Ubah Password
</div>
</div>
<div class="border-b-2 my-3 opacity-90"></div>
<div x-show="open === 'profile'" x-transition>
<div>
<form class="w-1/2" action="{{ route('profile.update')}}" method="POST" enctype="multipart/form-data">
@csrf
<div class="py-5">
<label for="photo" class="mb-2 block font-semibold">Photo</label>
<input type="file" name="photo" id="photo" class="border rounded p-2 w-full">
@error('photo')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
<div class="py-5">
<label for="name" class="mb-2 block font-semibold">Name</label>
<input type="text" name="name" id="name" class="border rounded p-2 w-full" value="{{ $data->name }}" placeholder="Masukkan Name">
@error('name')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
<div class="py-5">
<label for="email" class="mb-2 block font-semibold">Email</label>
<input type="email" name="email" id="email" class="border rounded p-2 w-full" value="{{ $data->email }}" placeholder="Masukkan Email">
@error('email')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
<div class="py-5">
<label for="phone" class="mb-2 block font-semibold">Phone</label>
<input type="number" name="phone" id="phone" class="border rounded p-2 w-full" value="{{ $data->phone }}" placeholder="Masukkan Phone">
@error('phone')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
<button type="submit" class="bg-yellow-500 text-white rounded p-2 w-fit">Simpan Perubahan</button>
</form>
</div>
</div>
<div x-show="open === 'password'" x-transition>
<div>
<form class="w-1/2" action="{{ route('password.update') }}" method="POST">
@csrf
<div class="py-5">
<label for="old_password" class="mb-2 block font-semibold">Password Lama</label>
<input type="password" name="old_password" id="old_password" class="border rounded p-2 w-full" placeholder="Masukkan Password Lama">
@error('old_password')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
<div class="py-5">
<label for="new_password" class="mb-2 block font-semibold">Password Baru</label>
<input type="password" name="new_password" id="new_password" class="border rounded p-2 w-full" placeholder="Masukkan Password Baru">
@error('new_password')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
<div class="py-5">
<label for="new_password_confirmation" class="mb-2 block font-semibold">Konfirmasi Password Baru</label>
<input type="password" name="new_password_confirmation" id="new_password_confirmation" class="border rounded p-2 w-full" placeholder="Masukkan Konfirmasi Password Baru">
@error('new_password_confirmation')
<span class="text-red-500 text-sm">{{ $message }}</span>
@enderror
</div>
<button type="submit" class="bg-yellow-500 text-white rounded p-2 w-fit">Simpan Perubahan</button>
</form>
</div>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,24 @@
@extends('layouts.app')
@section('content')
<form class="w-1/2" action="{{ route('sanksi.create') }}" method="POST">
@csrf
<div class="py-5">
<label for="rentang_point" class="mb-2 block font-semibold">Rentang Point</label>
<input type="text" name="rentang_point" id="rentang_point" class="border rounded p-2 w-full" placeholder="Masukkan Rentang Point" value="{{ old('rentang_point') }}">
@if($errors->has('rentang_point'))
<span class="text-red-500">{{ $errors->first('rentang_point') }}</span>
@endif
</div>
<div class="py-5">
<label for="jenis_sanksi" class="mb-2 block font-semibold">Jenis Sanksi</label>
<textarea name="jenis_sanksi" id="jenis_sanksi" class="border rounded p-2 w-full" placeholder="Masuklan Jenis Sanksi">{{ old('jenis_sanksi') }}</textarea>
@if($errors->has('jenis_sanksi'))
<span class="text-red-500">{{ $errors->first('jenis_sanksi') }}</span>
@endif
</div>
<button type="submit" class="bg-green-500 text-white rounded p-2 w-fit px-10">Simpan</button>
</form>
@endsection

View File

@ -0,0 +1,62 @@
@extends('layouts.app')
@section('content')
<div class="mb-10 flex justify-end items-center">
@if (Auth::user()->usertype === 'admin')
<a href="{{route('sanksi.create')}}" class="rounded text-white py-2 px-3 flex items-center" style="background-color: #1679AB;">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-3">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
</svg>
Tambah Data
</a>
@endif
</div>
<table id="table" class="display w-full">
<thead>
<tr>
<th>No</th>
<th>Kode Sanksi</th>
<th>Rentang Point</th>
<th>Jenis Sanksi</th>
@if (Auth::user()->usertype === 'admin')
<th>Action</th>
@endif
</tr>
</thead>
<tbody>
@foreach ($data as $index => $sanksi )
<tr>
<td>{{ $index + 1 }}</td>
<td>{{ $sanksi->kode_sanksi }}</td>
<td>{{ $sanksi->rentang_point }}</td>
<td>{{ $sanksi->jenis_sanksi }}</td>
@if (Auth::user()->usertype === 'admin')
<td class="flex text-white">
<a href="{{ route('sanksi.update', $sanksi->id)}}" class="bg-yellow-500 rounded-lg p-2 mr-3">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" />
</svg>
</a>
<a href="{{ route('sanksi.delete', $sanksi->id)}}" class="bg-red-500 rounded-lg p-2" onclick="return confirmDelete()">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
</svg>
</a>
</td>
@endif
</tr>
@endforeach
</tbody>
</table>
@endsection
@section('script')
<script>
$(document).ready(function() {
$('#table').DataTable();
});
</script>
@endsection

View File

@ -0,0 +1,24 @@
@extends('layouts.app')
@section('content')
<form class="w-1/2" action="{{ route('sanksi.update', $data->id) }}" method="POST">
@csrf
<div class="py-5">
<label for="rentang_point" class="mb-2 block font-semibold">Rentang Point</label>
<input type="text" name="rentang_point" id="rentang_point" class="border rounded p-2 w-full" placeholder="Masukkan Rentang Point" value="{{ old('rentang_point', $data->rentang_point) }}">
@if($errors->has('rentang_point'))
<span class="text-red-500">{{ $errors->first('rentang_point') }}</span>
@endif
</div>
<div class="py-5">
<label for="jenis_sanksi" class="mb-2 block font-semibold">Jenis Sanksi</label>
<textarea name="jenis_sanksi" id="jenis_sanksi" class="border rounded p-2 w-full" placeholder="Masukkan Sanksi Sekolah">{{ old('jenis_sanksi', $data->jenis_sanksi) }}</textarea>
@if($errors->has('jenis_sanksi'))
<span class="text-red-500">{{ $errors->first('jenis_sanksi') }}</span>
@endif
</div>
<button type="submit" class="bg-green-500 text-white rounded p-2 w-fit px-10">Simpan</button>
</form>
@endsection

View File

@ -0,0 +1,53 @@
@extends('layouts.app')
@section('content')
<form class="w-1/2" action="{{ route('siswa.create') }}" method="POST">
@csrf
<div class="py-5">
<label for="nama" class="mb-2 block font-semibold">Nama</label>
<input type="text" name="nama" id="nama" class="border rounded p-2 w-full" placeholder="Masukkan Nama" value="{{ old('nama') }}">
@if($errors->has('nama'))
<span class="text-red-500">{{ $errors->first('nama') }}</span>
@endif
</div>
<div class="py-5">
<label for="nis" class="mb-2 block font-semibold">NIS</label>
<input type="number" name="nis" id="nis" class="border rounded p-2 w-full" placeholder="Masukkan NIS" value="{{ old('nis') }}">
@if($errors->has('nis'))
<span class="text-red-500">{{ $errors->first('nis') }}</span>
@endif
</div>
<div class="py-5">
<label for="kelas" class="mb-2 block font-semibold">Kelas</label>
<input type="text" name="kelas" id="kelas" class="border rounded p-2 w-full" placeholder="Masukkan Kelas" value="{{ old('kelas') }}">
@if($errors->has('kelas'))
<span class="text-red-500">{{ $errors->first('kelas') }}</span>
@endif
</div>
<div class="py-5">
<label for="wali_kelas" class="mb-2 block font-semibold">Wali Kelas</label>
<select name="wali_kelas_id" id="wali_kelas_id" class="border rounded p-2 w-full js-example-basic-single">
<option value="" disabled selected>Masukkan Wali Kelas</option>
@foreach ($wali as $option)
<option value="{{ $option->id }}" {{ old('wali_kelas_id') == $option->id ? 'selected' : '' }}>
{{ $option->name }}
</option>
@endforeach
</select>
@if($errors->has('wali_kelas_id'))
<span class="text-red-500">{{ $errors->first('wali_kelas_id') }}</span>
@endif
</div>
<button type="submit" class="bg-green-500 text-white rounded p-2 w-fit px-10">Simpan</button>
</form>
@endsection
@section('script')
<script>
$(document).ready(function() {
$('.js-example-basic-single').select2();
});
</script>
@endsection

View File

@ -0,0 +1,66 @@
@extends('layouts.app')
@section('content')
<div class="mb-10 flex justify-end items-center">
@if (Auth::user()->usertype === 'admin')
<a href="{{route('siswa.create')}}" class="rounded text-white py-2 px-3 flex items-center" style="background-color: #1679AB;">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-3">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
</svg>
Tambah Data
</a>
@endif
</div>
<table id="table" class="display w-full">
<thead>
<tr>
<th>No</th>
<th>Nama</th>
<th>Tanggal</th>
<th>NIS</th>
<th>Kelas</th>
<th>Wali Kelas</th>
@if (Auth::user()->usertype === 'admin')
<th>Action</th>
@endif
</tr>
</thead>
<tbody>
@foreach ($data as $index => $siswa )
<tr>
<td>{{ $index + 1 }}</td>
<td>{{ $siswa->nama }}</td>
<td>{{ $siswa->created_at }}</td>
<td>{{ $siswa->nis }}</td>
<td>{{ $siswa->kelas }}</td>
<td>{{ $siswa->walikelas->name }}</td>
@if (Auth::user()->usertype === 'admin')
<td class="flex text-white">
<a href="{{ route('siswa.update', $siswa->id)}}" class="bg-yellow-500 rounded-lg p-2 mr-3">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" />
</svg>
</a>
<a href="{{ route('siswa.delete', $siswa->id)}}" class="bg-red-500 rounded-lg p-2" onclick="return confirmDelete()">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
</svg>
</a>
</td>
@endif
</tr>
@endforeach
</tbody>
</table>
@endsection
@section('script')
<script>
$(document).ready(function() {
$('#table').DataTable();
});
</script>
@endsection

View File

@ -0,0 +1,53 @@
@extends('layouts.app')
@section('content')
<form action="{{ url('dashboard/siswa/update/' . $data->id) }}" method="POST" class="w-1/2">
@csrf
<div class="py-5">
<label for="nama" class="mb-2 block font-semibold">Name</label>
<input type="text" name="nama" id="nama" class="border rounded p-2 w-full" value="{{ old('nama', $data->nama) }}" placeholder="Masukkan Nama">
@error('nama')
<div class="text-red-500">{{ $message }}</div>
@enderror
</div>
<div class="py-5">
<label for="nis" class="mb-2 block font-semibold">NIS</label>
<input type="number" name="nis" id="nis" class="border rounded p-2 w-full" value="{{ old('nis', $data->nis) }}" placeholder="Masukkan NIS">
@error('nis')
<div class="text-red-500">{{ $message }}</div>
@enderror
</div>
<div class="py-5">
<label for="kelas" class="mb-2 block font-semibold">Kelas</label>
<input type="text" name="kelas" id="kelas" class="border rounded p-2 w-full" value="{{ old('kelas', $data->kelas) }}" placeholder="Masukkan Kelas">
@error('kelas')
<div class="text-red-500">{{ $message }}</div>
@enderror
</div>
<div class="py-5">
<label for="wali_kelas_id" class="mb-2 block font-semibold">Wali Kelas</label>
<select name="wali_kelas_id" id="wali_kelas_id" class="border rounded p-2 w-full js-example-basic-single">
<option value="" disabled {{ old('wali_kelas_id', $data->wali_kelas_id) === null ? 'selected' : '' }}>Masukkan Wali Kelas</option>
@foreach ($wali as $option)
<option value="{{ $option->id }}" {{ old('wali_kelas_id', $data->wali_kelas_id) == $option->id ? 'selected' : '' }}>
{{ $option->name }}
</option>
@endforeach
</select>
@error('wali_kelas_id')
<div class="text-red-500">{{ $message }}</div>
@enderror
</div>
<button type="submit" class="bg-yellow-500 text-white rounded p-2 w-fit px-10">Simpan Perubahan</button>
</form>
@endsection
@section('script')
<script>
$(document).ready(function() {
$('.js-example-basic-single').select2();
});
</script>
@endsection

View File

@ -0,0 +1,24 @@
@extends('layouts.app')
@section('content')
<form class="w-1/2" action="{{ route('tindakan.create') }}" method="POST">
@csrf
<div class="py-5">
<label for="rentang_point" class="mb-2 block font-semibold">Rentang Point</label>
<input type="text" name="rentang_point" id="rentang_point" class="border rounded p-2 w-full" placeholder="Masukkan Rentang Point" value="{{ old('rentang_point') }}">
@if($errors->has('rentang_point'))
<span class="text-red-500">{{ $errors->first('rentang_point') }}</span>
@endif
</div>
<div class="py-5">
<label for="tindakan_sekolah" class="mb-2 block font-semibold">Tindakan Sekolah</label>
<textarea name="tindakan_sekolah" id="tindakan_sekolah" class="border rounded p-2 w-full" placeholder="Masukkan Rentang Point">{{ old('tindakan_sekolah') }}</textarea>
@if($errors->has('tindakan_sekolah'))
<span class="text-red-500">{{ $errors->first('tindakan_sekolah') }}</span>
@endif
</div>
<button type="submit" class="bg-green-500 text-white rounded p-2 w-fit px-10">Simpan</button>
</form>
@endsection

View File

@ -0,0 +1,62 @@
@extends('layouts.app')
@section('content')
<div class="mb-10 flex justify-end items-center">
@if (Auth::user()->usertype === 'admin')
<a href="{{route('tindakan.create')}}" class="rounded text-white py-2 px-3 flex items-center" style="background-color: #1679AB;">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-3">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
</svg>
Tambah Data
</a>
@endif
</div>
<table id="table" class="display w-full">
<thead>
<tr>
<th>No</th>
<th>Kode Tindakan</th>
<th>Rentang Point</th>
<th>Tindakan Sekolah</th>
@if (Auth::user()->usertype === 'admin')
<th>Action</th>
@endif
</tr>
</thead>
<tbody>
@foreach ($data as $index => $tindakan )
<tr>
<td>{{ $index + 1 }}</td>
<td>{{ $tindakan->kode_tindakan }}</td>
<td>{{ $tindakan->rentang_point }}</td>
<td>{{ $tindakan->tindakan_sekolah }}</td>
@if (Auth::user()->usertype === 'admin')
<td class="flex text-white">
<a href="{{ route('tindakan.update', $tindakan->id)}}" class="bg-yellow-500 rounded-lg p-2 mr-3">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" />
</svg>
</a>
<a href="{{ route('tindakan.delete', $tindakan->id)}}" class="bg-red-500 rounded-lg p-2" onclick="return confirmDelete()">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
</svg>
</a>
</td>
@endif
</tr>
@endforeach
</tbody>
</table>
@endsection
@section('script')
<script>
$(document).ready(function() {
$('#table').DataTable();
});
</script>
@endsection

View File

@ -0,0 +1,24 @@
@extends('layouts.app')
@section('content')
<form class="w-1/2" action="{{ route('tindakan.update', $data->id) }}" method="POST">
@csrf
<div class="py-5">
<label for="rentang_point" class="mb-2 block font-semibold">Rentang Point</label>
<input type="text" name="rentang_point" id="rentang_point" class="border rounded p-2 w-full" placeholder="Masukkan Rentang Point" value="{{ old('rentang_point', $data->rentang_point) }}">
@if($errors->has('rentang_point'))
<span class="text-red-500">{{ $errors->first('rentang_point') }}</span>
@endif
</div>
<div class="py-5">
<label for="tindakan_sekolah" class="mb-2 block font-semibold">Tindakan Sekolah</label>
<textarea name="tindakan_sekolah" id="tindakan_sekolah" class="border rounded p-2 w-full" placeholder="Masukkan Tindakan Sekolah">{{ old('tindakan_sekolah', $data->tindakan_sekolah) }}</textarea>
@if($errors->has('tindakan_sekolah'))
<span class="text-red-500">{{ $errors->first('tindakan_sekolah') }}</span>
@endif
</div>
<button type="submit" class="bg-green-500 text-white rounded p-2 w-fit px-10">Simpan</button>
</form>
@endsection

View File

@ -0,0 +1,55 @@
@extends('layouts.app')
@section('content')
<form class="w-1/2" action="{{ route('user.create')}}" method="POST">
@csrf
<div class="py-5">
<label for="name" class="mb-2 block font-semibold">Name</label>
<input type="text" name="name" id="name" class="border rounded p-2 w-full" placeholder="Masukkan Name" value="{{ old('name') }}">
@error('name')
<p class="text-red-500 mt-1">{{ $message }}</p>
@enderror
</div>
<div class="py-5">
<label for="email" class="mb-2 block font-semibold">Email</label>
<input type="email" name="email" id="email" class="border rounded p-2 w-full" placeholder="Masukkan Email" value="{{ old('email') }}">
@error('email')
<p class="text-red-500 mt-1">{{ $message }}</p>
@enderror
</div>
<div class="py-5">
<label for="password" class="mb-2 block font-semibold">Password</label>
<input type="password" name="password" id="password" class="border rounded p-2 w-full" placeholder="Masukkan Password">
@error('password')
<p class="text-red-500 mt-1">{{ $message }}</p>
@enderror
</div>
<div class="py-5">
<label for="password_confirmation" class="mb-2 block font-semibold">Confirm Password</label>
<input type="password" name="password_confirmation" id="password_confirmation" class="border rounded p-2 w-full" placeholder="Konfirmasi Password">
@error('password_confirmation')
<p class="text-red-500 mt-1">{{ $message }}</p>
@enderror
</div>
<div class="py-5">
<label for="phone" class="mb-2 block font-semibold">Phone</label>
<input type="number" name="phone" id="phone" class="border rounded p-2 w-full" placeholder="Masukkan Phone" value="{{ old('phone') }}">
@error('phone')
<p class="text-red-500 mt-1">{{ $message }}</p>
@enderror
</div>
<div class="py-5">
<label for="usertype" class="mb-2 block font-semibold">Role</label>
<select name="usertype" id="usertype" class="border rounded p-2 w-full">
<option value="admin" {{ old('usertype') == 'admin' ? 'selected' : '' }}>Admin</option>
<option value="bk/guru" {{ old('usertype') == 'bk/guru' ? 'selected' : '' }}>BK/Guru</option>
</select>
@error('usertype')
<p class="text-red-500 mt-1">{{ $message }}</p>
@enderror
</div>
<button type="submit" class="bg-green-500 text-white rounded p-2 w-fit px-10">Simpan</button>
</form>
@endsection

View File

@ -0,0 +1,61 @@
@extends('layouts.app')
@section('content')
<div class="mb-10 flex justify-end items-center">
@if (Auth::user()->usertype === 'admin')
<a href="{{route('user.create')}}" class="rounded text-white py-2 px-3 flex items-center" style="background-color: #1679AB;">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-3">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
</svg>
Tambah Data
</a>
@endif
</div>
<table id="table" class="display w-full">
<thead>
<tr>
<th>No</th>
<th>Nama</th>
<th>Email</th>
<th>Phone</th>
@if (Auth::user()->usertype === 'admin')
<th>Action</th>
@endif
</tr>
</thead>
<tbody>
@foreach ($data as $index => $user )
<tr>
<td>{{ $index + 1 }}</td>
<td>{{ $user->name }}</td>
<td>{{ $user->email }}</td>
<td>{{ $user->phone }}</td>
@if (Auth::user()->usertype === 'admin')
<td class="flex text-white">
<a href="{{ route('user.update', $user->id)}}" class="bg-yellow-500 rounded-lg p-2 mr-3">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" />
</svg>
</a>
<a href="{{ route('user.delete', $user->id)}}" class="bg-red-500 rounded-lg p-2" onclick="return confirmDelete()">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
</svg>
</a>
</td>
@endif
</tr>
@endforeach
</tbody>
</table>
@endsection
@section('script')
<script>
$(document).ready(function() {
$('#table').DataTable();
});
</script>
@endsection

View File

@ -0,0 +1,50 @@
@extends('layouts.app')
@section('content')
<form class="w-1/2" action="{{ route('user.update', $data->id) }}" method="POST">
@csrf
<div class="py-5">
<label for="name" class="mb-2 block font-semibold">Name</label>
<input type="text" name="name" id="name" class="border rounded p-2 w-full" value="{{ old('name', $data->name) }}" placeholder="Masukkan Name">
@if($errors->has('name'))
<div class="text-red-500 mt-2">
{{ $errors->first('name') }}
</div>
@endif
</div>
<div class="py-5">
<label for="email" class="mb-2 block font-semibold">Email</label>
<input type="email" name="email" id="email" class="border rounded p-2 w-full" value="{{ old('email', $data->email) }}" placeholder="Masukkan Email">
@if($errors->has('email'))
<div class="text-red-500 mt-2">
{{ $errors->first('email') }}
</div>
@endif
</div>
<div class="py-5">
<label for="phone" class="mb-2 block font-semibold">Phone</label>
<input type="number" name="phone" id="phone" class="border rounded p-2 w-full" value="{{ old('phone', $data->phone) }}" placeholder="Masukkan Phone">
@if($errors->has('phone'))
<div class="text-red-500 mt-2">
{{ $errors->first('phone') }}
</div>
@endif
</div>
<div class="py-5">
<label for="usertype" class="mb-2 block font-semibold">Role</label>
<select name="usertype" id="usertype" class="border rounded p-2 w-full">
<option value="{{ $data->usertype }}" selected>{{ $data->usertype }}</option>
<option value="admin" {{ old('usertype', $data->usertype) == 'admin' ? 'selected' : '' }}>Admin</option>
<option value="bk/guru" {{ old('usertype', $data->usertype) == 'bk/guru' ? 'selected' : '' }}>BK/Guru</option>
</select>
@if($errors->has('usertype'))
<div class="text-red-500 mt-2">
{{ $errors->first('usertype') }}
</div>
@endif
</div>
<button type="submit" class="bg-yellow-500 text-white rounded p-2 w-fit px-10">Simpan Perubahan</button>
</form>
@endsection

8
routes/console.php Normal file
View File

@ -0,0 +1,8 @@
<?php
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote')->hourly();

101
routes/web.php Normal file
View File

@ -0,0 +1,101 @@
<?php
use App\Http\Controllers\AuthController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\JenisPelanggaranController;
use App\Http\Controllers\KriteriaPelanggaranController;
use App\Http\Controllers\PelanggaranController;
use App\Http\Controllers\SanksiController;
use App\Http\Controllers\SiswaController;
use App\Http\Controllers\TindakanController;
use App\Http\Controllers\UserController;
use Illuminate\Support\Facades\Route;
use App\Http\Middleware\isAuthenticatedAs;
Route::middleware('guest')->group(function () {
Route::controller(AuthController::class)->group(function () {
Route::match(['GET', 'POST'], '/', 'login')->name('login');
Route::match(['GET', 'POST'], 'register', 'register')->name('register');
});
});
Route::middleware('auth')->group(function () {
Route::prefix('dashboard')->group(function () {
Route::controller(DashboardController::class)->group(function () {
Route::match(['GET', 'POST'], '/', 'index')->name('dashboard');
Route::match(['GET'], 'logout', 'logout')->name('dashboard.logout');
Route::prefix('profile')->group(function () {
Route::match(['GET', 'POST'], '/', 'updateProfile')->name('profile.update');
Route::match(['POST'], 'password', 'updatePassword')->name('password.update');
});
});
Route::middleware('isAuthenticatedAs:admin')->group(function() {
Route::prefix('user')->group(function () {
Route::controller(UserController::class)->group(function () {
Route::match(['GET'], '/', 'index')->name('user');
Route::match(['GET', 'POST'], 'create', 'create')->name('user.create');
Route::match(['GET', 'POST'], 'update/{id}', 'update')->name('user.update');
Route::match(['GET'], 'delete/{id}', 'delete')->name('user.delete');
});
});
});
Route::prefix('sanksi')->group(function () {
Route::controller(SanksiController::class)->group(function () {
Route::match(['GET'], '/', 'index')->name('sanksi');
Route::middleware('isAuthenticatedAs:admin')->group(function() {
Route::match(['GET', 'POST'], 'create', 'create')->name('sanksi.create');
Route::match(['GET', 'POST'], 'update/{id}', 'update')->name('sanksi.update');
Route::match(['GET'], 'delete/{id}', 'delete')->name('sanksi.delete');
});
});
});
Route::prefix('siswa')->group(function () {
Route::controller(SiswaController::class)->group(function () {
Route::match(['GET'], '/', 'index')->name('siswa');
Route::middleware('isAuthenticatedAs:admin')->group(function() {
Route::match(['GET', 'POST'], 'create', 'create')->name('siswa.create');
Route::match(['GET', 'POST'], 'update/{id}', 'update')->name('siswa.update');
Route::match(['GET'], 'delete/{id}', 'delete')->name('siswa.delete');
});
});
});
Route::prefix('tindakan')->group(function () {
Route::controller(TindakanController::class)->group(function () {
Route::match(['GET'], '/', 'index')->name('tindakan');
Route::middleware('isAuthenticatedAs:admin')->group(function() {
Route::match(['GET', 'POST'], 'create', 'create')->name('tindakan.create');
Route::match(['GET', 'POST'], 'update/{id}', 'update')->name('tindakan.update');
Route::match(['GET'], 'delete/{id}', 'delete')->name('tindakan.delete');
});
});
});
Route::prefix('pelanggaran')->group(function () {
Route::controller(PelanggaranController::class)->group(function () {
Route::match(['GET'], '/', 'index')->name('pelanggaran');
Route::match(['GET', 'POST'], 'create', 'create')->name('pelanggaran.create');
Route::match(['GET', 'POST'], 'detail/{id}', 'detail')->name('pelanggaran.detail');
Route::match(['GET', 'POST'], 'update/{id}', 'update')->name('pelanggaran.update');
Route::match(['GET'], 'delete/{id}', 'delete')->name('pelanggaran.delete');
});
});
Route::middleware('isAuthenticatedAs:admin')->group(function() {
Route::prefix('kriteriapelanggaran')->group(function () {
Route::controller(KriteriaPelanggaranController::class)->group(function () {
Route::match(['GET', 'POST'], 'create', 'create')->name('kriteriapelanggaran.create');
Route::match(['GET', 'POST'], 'update/{id}', 'update')->name('kriteriapelanggaran.update');
Route::match(['GET'], 'delete/{id}', 'delete')->name('kriteriapelanggaran.delete');
});
});
});
Route::prefix('jenispelanggaran')->group(function () {
Route::controller(JenisPelanggaranController::class)->group(function () {
Route::match(['GET'], '/', 'index')->name('jenispelanggaran');
Route::middleware('isAuthenticatedAs:admin')->group(function() {
Route::match(['GET', 'POST'], 'create', 'create')->name('jenispelanggaran.create');
Route::match(['GET', 'POST'], 'update/{id}', 'update')->name('jenispelanggaran.update');
Route::match(['GET'], 'delete/{id}', 'delete')->name('jenispelanggaran.delete');
});
});
});
});
});

3
storage/app/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*
!public/
!.gitignore

2
storage/app/public/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

9
storage/framework/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
compiled.php
config.php
down
events.scanned.php
maintenance.php
routes.php
routes.scanned.php
schedule-*
services.json

3
storage/framework/cache/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*
!data/
!.gitignore

Some files were not shown because too many files have changed in this diff Show More