Commit 7bc4b361 by Siti Aisah

add master data

parent b519b6b4
......@@ -2,8 +2,13 @@
namespace App\Http\Controllers\Admin;
use App\Http\Support\ValidationRule;
use Illuminate\Support\Facades\Hash;
use App\Http\Controllers\Controller;
use App\Models\Kegiatan;
use App\Models\Konferensi;
use App\Models\Registrasi;
use App\Models\User;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
......@@ -11,6 +16,278 @@
class AdminController extends Controller
{
public function index() {
return view('home');
}
public function index_user() {
$user = User::get();
$data = [
'user' => $user,
];
return view('admin.user.index', $data);
}
public function store_user(Request $request) {
$rules = [
'name' => 'required|string',
'email' => 'required|email',
'password' => 'string|min:8',
];
$request->validate($rules, ValidationRule::getErrorMessage($rules));
DB::beginTransaction();
try{
$password = Hash::make($request->password);
$data = [
'name' => strip_tags($request->name),
'email' => strip_tags($request->email),
'password' => $password
];
User::query()->create($data);
DB::commit();
return redirect()->back()
->with('success', 'Data saved successfully');
}
catch(Exception $e){
Log::error($e);
DB::rollBack();
return redirect()->back()
->with('error', 'Data failed to save');
}
}
public function update_user($id, Request $request){
DB::beginTransaction();
try{
if($request->password){
$password = Hash::make($request->password);
}
else{
$user = User::query()->where('id', $id)->first();
$password = $user->password;
}
$data = [
'name' => strip_tags($request->name),
'email' => strip_tags($request->email),
'password' => $password
];
User::query()->where('id', $id)->update($data);
DB::commit();
return redirect()->back()
->with('success', 'Data saved successfully');
}
catch(Exception $e){
Log::error($e);
DB::rollBack();
return redirect()->back()
->with('error', 'Data failed to update');
}
}
public function delete_user($id){
DB::beginTransaction();
try{
User::find($id)->delete();
DB::commit();
return redirect()->back()
->with('success', 'Data deleted successfully');
}
catch(Exception $e){
Log::error($e);
DB::rollBack();
return redirect()->back()
->with('error', 'Data failed to delete');
}
}
public function index_kegiatan() {
$kegiatan = Kegiatan::get();
$data = [
'kegiatan' => $kegiatan
];
return view('admin.kegiatan.index', $data);
}
public function store_kegiatan(Request $request) {
$rules = [
'nama' => 'required|string',
'harga' => 'required|numeric'
];
$request->validate($rules, ValidationRule::getErrorMessage($rules));
DB::beginTransaction();
try{
$data = [
'nama' => $request->nama,
'harga' => $request->harga
];
Kegiatan::query()->create($data);
DB::commit();
return redirect()->back()
->with('success', 'Data saved successfully');
}
catch(Exception $e){
Log::error($e);
DB::rollBack();
return redirect()->back()
->with('error', 'Data failed to create');
}
}
public function update_kegiatan($id, Request $request) {
$rules = [
'nama' => 'required|string',
'harga' => 'required|numeric'
];
$request->validate($rules, ValidationRule::getErrorMessage($rules));
DB::beginTransaction();
try{
$data = [
'nama' => $request->nama,
'harga' => $request->harga
];
Kegiatan::query()->where('id', $id)->update($data);
DB::commit();
return redirect()->back()
->with('success', 'Data saved successfully');
}
catch(Exception $e){
Log::error($e);
DB::rollBack();
return redirect()->back()
->with('error', 'Data failed to update');
}
}
public function delete_kegiatan($id) {
DB::beginTransaction();
try{
Kegiatan::find($id)->delete();
DB::commit();
return redirect()->back()
->with('success', 'Data deleted successfully');
}
catch(Exception $e){
Log::error($e);
DB::rollBack();
return redirect()->back()
->with('error', 'Data failed to delete');
}
}
public function index_konferensi() {
$konferensi = Konferensi::get();
$data = [
'konferensi' => $konferensi
];
return view('admin.konferensi.index', $data);
}
public function store_konferensi(Request $request) {
$rules = [
'nama' => 'required|string'
];
$request->validate($rules, ValidationRule::getErrorMessage($rules));
DB::beginTransaction();
try{
$data = [
'nama' => strip_tags($request->nama)
];
Konferensi::query()->create($data);
DB::commit();
return redirect()->back()
->with('success', 'Data saved successfully');
}
catch(Exception $e){
Log::error($e);
DB::rollBack();
return redirect()->back()
->with('error', 'Data failed to update');
}
}
public function update_konferensi($id, Request $request) {
$rules = [
'nama' => 'required|string'
];
$request->validate($rules, ValidationRule::getErrorMessage($rules));
DB::beginTransaction();
try{
$data = [
'nama' => $request->nama
];
Konferensi::query()->where('id', $id)->update($data);
DB::commit();
return redirect()->back()
->with('success', 'Data saved successfully');
}
catch(Exception $e){
Log::error($e);
DB::rollBack();
return redirect()->back()
->with('error', 'Data failed to update');
}
}
public function delete_konferensi($id) {
DB::beginTransaction();
try{
Konferensi::find($id)->delete();
DB::commit();
return redirect()->back()
->with('success', 'Data deleted successfully');
}
catch(Exception $e){
Log::error($e);
DB::rollBack();
return redirect()->back()
->with('error', 'Data failed to delete');
}
}
public function index_peserta(){
$peserta = Registrasi::with('pkKegiatan', 'pkKonferensi')->get();
$data = [
......@@ -20,16 +297,21 @@ public function index_peserta(){
return view('admin.peserta.index', $data);
}
public function delete_participant($id) {
public function delete_peserta($id) {
DB::beginTransaction();
try{
Registrasi::find($id)->delete();
DB::commit();
return redirect()->back()
->with('success', 'Data deleted successfully');
}
catch(Exception $e){
Log::error($e);
DB::rollBack();
return redirect()->back()
->with('error', 'Data failed to delete');
}
}
}
......@@ -4,9 +4,9 @@
class ValidationRule{
const WARNING = [
'required' => 'can not be empty',
'numeric' => 'must be a number',
'string' => 'must be a string',
'required' => 'inputan tidak boleh kosong',
'numeric' => 'inputan harus berupa angka',
'string' => 'inputan harus berupa teks',
'max' => 'must be maximum',
'min' => 'must be minimum',
'email' => 'is invalid',
......
......@@ -29,7 +29,7 @@
<th>Instansi</th>
<th>Kegiatan</th>
<th>Konferensi</th>
<th>Action</th>
<th>Aksi</th>
</tr>
</thead>
<tbody>
......@@ -89,10 +89,10 @@
@csrf
<div class="modal-body" @if ($errors->has('nama')) has-error @endif>
<div class="form-group" style="text-align: center">
<h5 class="address-title text-center mb-1" id="addNewAddressTitle">Are you sure you want to delete the data</h5>
<h5 class="address-title text-center mb-1" id="addNewAddressTitle">Apakah Anda yakin akan menghapus data ini?</h5>
</div>
<button type="submit" class="btn btn-primary ml-1">Delete</button>
<button type="button" class="btn btn-light-secondary" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary ml-1">Hapus</button>
<button type="button" class="btn btn-light-secondary" data-dismiss="modal">Batal</button>
</div>
</form>
</div>
......
@extends('layouts.app')
@section('title','Beranda')
@section('sidebar')
@parent
@endsection
@section('content')
<section class="section">
<div class="section-header">
<h1>Welcome to KONASPI 2024</h1>
</div>
<div class="section-body">
<div class="row mt-4 active" id="tab-semuapengajuan" data-tab-group="mygroup-tab">
<div class="col-12">
<div class="card">
<div class="card-body">
<h5 style="color: rgb(37, 94, 218);">Konvensi Nasional Pendidikan Indonesia (KONASPI) XI</h5>
<h6 style="color: black;">10-12 September 2024 | Universitas Negeri Surabaya</h6>
</div>
</div>
</div>
</div>
</section>
@endsection
@section('footer')
@parent
@endsection
......@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>@yield('title') - JWG 2024</title>
<title>@yield('title') - KONASPI XI 2024</title>
<!-- General CSS Files -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
......
@section('sidebar')
<aside id="sidebar-wrapper">
<div class="sidebar-brand">
<a href="/">JWG 2024</a>
<a href="/">KONASPI XI 2024</a>
</div>
<div class="sidebar-brand sidebar-brand-sm" >
<a href="/">JWG 2024</a>
<a href="/">KONASPI XI 2024</a>
</div>
<br>
<ul class="sidebar-menu" id="mySidebar">
......@@ -13,20 +13,17 @@
<a class="nav-link" href=""><i class="fas fa-home"></i><span>Home</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href=""><i class="fa fa-users"></i><span>Participant Data</span></a>
<a class="nav-link" href=""><i class="fa fa-users"></i><span>Data Peserta</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href=""><i class="fa fa-id-card"></i><span>Profile</span></a>
<a class="nav-link" href=""><i class="fa fa-suitcase"></i><span>Master Kegiatan</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href=""><i class="fa fa-suitcase"></i><span>Thematic Workshop</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href=""><i class="fa fa-user-circle"></i><span>User Management</span></a>
<a class="nav-link" href=""><i class="fa fa-user-circle"></i><span>Master Konferensi</span></a>
</li>
@else
<li class="nav-item">
<a class="nav-link" href=""><i class="fas fa-file-pen"></i><span>Inscription/Registration</span></a>
<a class="nav-link" href="{{route('user.create')}}"><i class="fas fa-file-pen"></i><span>Registrasi</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href=""><i class="fa fa-sign-in"></i><span>Login</span></a>
......
......@@ -19,11 +19,22 @@
Route::post('/store', [RegistrasiController::class,'store'])->name('user.store');
Route::get('/home', [AdminController::class,'index'])->name('admin.home');
Route::get('/user', [AdminController::class, 'index_user'])->name('admin.index_user');
Route::get('/kegiatan', [AdminController::class, 'index_workshop'])->name('admin.index_kegiatan');
Route::put('/updatekegiatan/{id}', [AdminController::class, 'update_workshop'])->name('admin.update_kegiatan');
Route::get('/deletekegiatan/{id}', [AdminController::class, 'delete_workshop'])->name('admin.delete_kegiatan');
Route::post('/createuser', [AdminController::class, 'store_user'])->name('admin.create_user');
Route::put('/updateuser/{id}', [AdminController::class, 'update_user'])->name('admin.update_user');
Route::get('/deleteuser/{id}', [AdminController::class, 'delete_user'])->name('admin.delete_user');
Route::get('/kegiatan', [AdminController::class, 'index_kegiatan'])->name('admin.index_kegiatan');
Route::post('/createkegiatan', [AdminController::class, 'store_kegiatan'])->name('admin.create_kegiatan');
Route::put('/updatekegiatan/{id}', [AdminController::class, 'update_kegiatan'])->name('admin.update_kegiatan');
Route::get('/deletekegiatan/{id}', [AdminController::class, 'delete_kegiatan'])->name('admin.delete_kegiatan');
Route::get('/konferensi', [AdminController::class, 'index_konferensi'])->name('admin.index_konferensi');
Route::post('/createkonferensi', [AdminController::class, 'store_konferensi'])->name('admin.create_konferensi');
Route::put('/updatekonferensi/{id}', [AdminController::class, 'update_konferensi'])->name('admin.update_konferensi');
Route::get('/deletekonferensi/{id}', [AdminController::class, 'delete_konferensi'])->name('admin.delete_konferensi');
Route::get('/peserta', [AdminController::class, 'index_peserta'])->name('admin.index_peserta');
Route::get('/download_peserta', [AdminController::class, 'download_peserta'])->name('admin.download_peserta');
Route::get('/delete_participant/{id}', [AdminController::class, 'delete_participant'])->name('admin.delete_peserta');
Route::get('/delete_peserta/{id}', [AdminController::class, 'delete_peserta'])->name('admin.delete_peserta');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment