diff --git a/app/Http/Controllers/SiswaController.php b/app/Http/Controllers/SiswaController.php index c3d9d90..80df48f 100644 --- a/app/Http/Controllers/SiswaController.php +++ b/app/Http/Controllers/SiswaController.php @@ -65,6 +65,8 @@ class SiswaController extends Controller if($request->is_yatim != null){ $siswa->is_yatim = 1; + }else{ + $siswa->is_yatim = 0; } if($siswa->save()){ diff --git a/app/Http/Controllers/TagihanController.php b/app/Http/Controllers/TagihanController.php index 398f543..7f8b244 100644 --- a/app/Http/Controllers/TagihanController.php +++ b/app/Http/Controllers/TagihanController.php @@ -83,17 +83,6 @@ class TagihanController extends Controller } } - /** - * Display the specified resource. - * - * @param int $id - * @return \Illuminate\Http\Response - */ - public function show($id) - { - // - } - /** * Show the form for editing the specified resource. * diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 0e98e80..0755c08 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use App\User; class UserController extends Controller { @@ -13,7 +14,7 @@ class UserController extends Controller */ public function index() { - $users = App\User::orderBy('created_at','desc')->paginate(5); + $users = User::orderBy('created_at','desc')->paginate(5); return view('users.index', ['users' => $users]); } @@ -24,7 +25,7 @@ class UserController extends Controller */ public function create() { - // + return view('users.form'); } /** @@ -35,18 +36,24 @@ class UserController extends Controller */ public function store(Request $request) { - // - } + $request->validate([ + 'name' => 'required|max:255', + 'email' => 'required|email|unique:users', + 'password' => 'required|confirmed|min:8', + 'role' => 'required|in:SuperAdmin,Admin,Bendahara' + ]); - /** - * Display the specified resource. - * - * @param int $id - * @return \Illuminate\Http\Response - */ - public function show($id) - { - // + if(User::create($request->input())){ + return redirect()->route('user.index')->with([ + 'type' => 'success', + 'msg' => 'Pengguna ditambahkan' + ]); + }else{ + return redirect()->route('user.index')->with([ + 'type' => 'danger', + 'msg' => 'Err.., Terjadi Kesalahan' + ]); + } } /** @@ -55,9 +62,9 @@ class UserController extends Controller * @param int $id * @return \Illuminate\Http\Response */ - public function edit($id) + public function edit(User $user) { - // + return view('users.form', ['user' => $user]); } /** @@ -67,9 +74,32 @@ class UserController extends Controller * @param int $id * @return \Illuminate\Http\Response */ - public function update(Request $request, $id) + public function update(Request $request, User $user) { - // + $request->validate([ + 'name' => 'required|max:255', + 'email' => 'required|email|unique:users,email,'.$user->id, + 'password' => 'nullable|confirmed|min:8', + 'role' => 'required|in:SuperAdmin,Admin,Bendahara' + ]); + + if($request->password != null){ + $user->fill($request->input()); + }else{ + $user->fill($request->except('password')); + } + + if($user->save()){ + return redirect()->route('user.index')->with([ + 'type' => 'success', + 'msg' => 'Pengguna diubah' + ]); + }else{ + return redirect()->route('user.index')->with([ + 'type' => 'danger', + 'msg' => 'Err.., Terjadi Kesalahan' + ]); + } } /** @@ -78,8 +108,18 @@ class UserController extends Controller * @param int $id * @return \Illuminate\Http\Response */ - public function destroy($id) + public function destroy(User $user) { - // + if($user->delete()){ + return redirect()->route('user.index')->with([ + 'type' => 'success', + 'msg' => 'Pengguna dihapus' + ]); + }else{ + return redirect()->route('user.index')->with([ + 'type' => 'danger', + 'msg' => 'Err.., Terjadi Kesalahan' + ]); + } } } diff --git a/resources/views/kelas/index.blade.php b/resources/views/kelas/index.blade.php index 2455488..508ea55 100644 --- a/resources/views/kelas/index.blade.php +++ b/resources/views/kelas/index.blade.php @@ -17,7 +17,7 @@ Tambah Kelas @if(session()->has('msg')) -
No. | @@ -48,14 +48,14 @@{{ $item->jumlah_idr }} | -+ |
@if($item->wajib_semua != null)
Wajib Semua @elseif($item->kelas_id != null){{ $item->kelas->nama }} {{ isset($item->kelas->periode) ? ' - '.$item->kelas->periode->nama : '' }} @elseif($item->wajib_semua == null && $item->kelas_id == null) @foreach ($item->role as $role) - {{ $role->siswa->nama }}{{ " (".$role->siswa->kelas->nama.")" }}, + {{ $role->siswa->nama }}{{ " (".$role->siswa->kelas->nama.")" }}, @endforeach @endif |
diff --git a/resources/views/users/form.blade.php b/resources/views/users/form.blade.php
index e69de29..3bcba28 100644
--- a/resources/views/users/form.blade.php
+++ b/resources/views/users/form.blade.php
@@ -0,0 +1,69 @@
+@extends('layouts.app')
+
+@section('site-name','Sistem Informasi SPP')
+@section('page-name', (isset($user) ? 'Ubah Pengguna' : 'Pengguna Baru'))
+
+@section('content')
+
---|
No. | +Nama | +Tanggal | +Status | ++ | |
---|---|---|---|---|---|
{{ $index+1 }} | ++ @if(Auth::user()->id == $item->id) + {{ $item->name }} + @else + {{ $item->name }} + @endif + | +{{ $item->email }} | +{{ $item->created_at->format('d-m-Y') }} | +{{ $item->role }} | ++ + + + @if(Auth::user()->id != $item->id) + + + + @endif + + | +