list_user admin side
This commit is contained in:
parent
1cd1a5bb4e
commit
a325a83288
|
@ -14,7 +14,7 @@ class ListUserController extends Controller
|
||||||
//
|
//
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$users = User::all()->where('kelas_user', '3');;
|
$users = User::all()->where('kelas_user', '3');
|
||||||
return view('admin_backend.admin_listuser', compact('users'));
|
return view('admin_backend.admin_listuser', compact('users'));
|
||||||
}
|
}
|
||||||
// /**
|
// /**
|
||||||
|
@ -23,36 +23,6 @@ public function index()
|
||||||
// * @param array $data
|
// * @param array $data
|
||||||
// * @return \Illuminate\Contracts\Validation\Validator
|
// * @return \Illuminate\Contracts\Validation\Validator
|
||||||
// */
|
// */
|
||||||
// protected function validator(array $data)
|
|
||||||
// {
|
|
||||||
// return Validator::make($data, [
|
|
||||||
// 'nama_lengkap' => ['required', 'string', 'max:255'],
|
|
||||||
// 'nim' => ['required', 'string', 'max:20'],
|
|
||||||
// 'semester' => ['required', 'integer', 'max:12'],
|
|
||||||
// 'angkatan' => ['required', 'integer', 'max:2250'],
|
|
||||||
// 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
|
||||||
// 'password' => ['required', 'string', 'min:8', 'confirmed'],
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Create a new user instance after a valid registration.
|
|
||||||
// *
|
|
||||||
// * @param array $data
|
|
||||||
// * @return \App\Models\User
|
|
||||||
// */
|
|
||||||
// protected function create(array $data)
|
|
||||||
// {
|
|
||||||
// return User::create([
|
|
||||||
// 'nama_lengkap' => $data['nama_lengkap'],
|
|
||||||
// 'nim' => $data['nim'],
|
|
||||||
// 'semester' => $data['semester'],
|
|
||||||
// 'angkatan' => $data['angkatan'],
|
|
||||||
// 'email' => $data['email'],
|
|
||||||
// 'password' => Hash::make($data['password']),
|
|
||||||
// 'kelas_user' => '1',
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
|
@ -69,4 +39,13 @@ public function store(Request $request)
|
||||||
|
|
||||||
return response()->json(['message' => 'User ditambahkan'], 201);
|
return response()->json(['message' => 'User ditambahkan'], 201);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$user = User::findOrFail($id);
|
||||||
|
$user->delete();
|
||||||
|
return redirect()->route('adminListUser.index')->with('success', 'User tersebut telah dihapus');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public function index()
|
||||||
$idUser = auth()->user()->id;
|
$idUser = auth()->user()->id;
|
||||||
$historiPengisian = Hasil::where('id_user', $idUser)->where('id_periode', $checkPeriod->id_periode)->get();
|
$historiPengisian = Hasil::where('id_user', $idUser)->where('id_periode', $checkPeriod->id_periode)->get();
|
||||||
|
|
||||||
$results = Hasil::with('user')->with('periode')->get();
|
$results = Hasil::with('user')->with('periode')->where('id_user', $idUser)->get();
|
||||||
$results = $results->map(function ($result) {
|
$results = $results->map(function ($result) {
|
||||||
$result->formatted_created_at = Carbon::parse($result->created_at)->format('d M Y');
|
$result->formatted_created_at = Carbon::parse($result->created_at)->format('d M Y');
|
||||||
if ($result->periode->semester == 1) {
|
if ($result->periode->semester == 1) {
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
<th>Angkatan</th>
|
<th>Angkatan</th>
|
||||||
<th>E-Mail</th>
|
<th>E-Mail</th>
|
||||||
<th>Role</th>
|
<th>Role</th>
|
||||||
|
<th>Aksi</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -49,6 +50,13 @@
|
||||||
echo "Mahasiswa";
|
echo "Mahasiswa";
|
||||||
} ?>
|
} ?>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<form action="{{ route('adminListUser.destroy', [$user->id]) }}" class="d-inline delete-form" method="POST">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<button class="btn btn-outline-danger btn-sm mt-1 mt-sm-0"><i class="bi bi-trash"></i>Hapus</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
<!-- Tambahkan kolom-kolom lain yang ingin Anda tampilkan -->
|
<!-- Tambahkan kolom-kolom lain yang ingin Anda tampilkan -->
|
||||||
</tr>
|
</tr>
|
||||||
<?php $i++;?>
|
<?php $i++;?>
|
||||||
|
@ -72,5 +80,25 @@
|
||||||
$("#users-nav").addClass("show");
|
$("#users-nav").addClass("show");
|
||||||
$("#sidebar-item-listuser").addClass("active");
|
$("#sidebar-item-listuser").addClass("active");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// hapus user
|
||||||
|
$('.delete-form').click(function(event){
|
||||||
|
event.preventDefault();
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Yakin untuk dihapus?',
|
||||||
|
text: "Kamu tidak akan bisa mengembalikan ini!",
|
||||||
|
icon: 'warning',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: '#dc3545',
|
||||||
|
cancelButtonColor: '#6c757d',
|
||||||
|
confirmButtonText: 'Ya, hapus ini!',
|
||||||
|
cancelButtonText: 'Batalkan',
|
||||||
|
reverseButtons: true
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
$(this).submit();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
Loading…
Reference in New Issue