diff --git a/app/Http/Controllers/DataSoalController.php b/app/Http/Controllers/DataSoalController.php index 176bd9c..6dfb963 100644 --- a/app/Http/Controllers/DataSoalController.php +++ b/app/Http/Controllers/DataSoalController.php @@ -39,7 +39,20 @@ public function create() */ public function store(Request $request) { - // + DataSoalModel::create([ + 'pertanyaan' => $request->pertanyaan, + 'jawaban_a' => $request->jawaban_a, + 'jawaban_b' => $request->jawaban_b, + 'jawaban_c' => $request->jawaban_c, + 'jawaban_d' => $request->jawaban_d, + 'jawaban_e' => $request->jawaban_e, + 'jawaban_benar' => $request->jawaban_benar, + ]); + + return response()->json([ + 'status' => true, + 'msg' => 'Data berhasil ditambahkan' + ]); } /** @@ -47,7 +60,11 @@ public function store(Request $request) */ public function show(string $id) { - // + $data = DataSoalModel::where('id_soal', $id)->get(); + return response()->json([ + 'status' => true, + 'data' => $data[0] + ]); } /** @@ -55,7 +72,11 @@ public function show(string $id) */ public function edit(string $id) { - // + $data = DataSoalModel::where('id_soal', $id)->get(); + return response()->json([ + 'status' => true, + 'data' => $data[0] + ]); } /** @@ -63,7 +84,20 @@ public function edit(string $id) */ public function update(Request $request, string $id) { - // + $data = DataSoalModel::where('id_soal', $id)->update([ + 'pertanyaan' => $request->pertanyaan, + 'jawaban_a' => $request->jawaban_a, + 'jawaban_b' => $request->jawaban_b, + 'jawaban_c' => $request->jawaban_c, + 'jawaban_d' => $request->jawaban_d, + 'jawaban_e' => $request->jawaban_e, + 'jawaban_benar' => $request->jawaban_benar, + ]); + + return response()->json([ + 'status' => true, + 'msg' => 'Data berhasil di edit' + ]); } /** @@ -71,6 +105,11 @@ public function update(Request $request, string $id) */ public function destroy(string $id) { - // + $data = DataSoalModel::where('id_soal', $id)->delete(); + + return response()->json([ + 'status' => true, + 'msg' => 'Data berhasil di hapus' + ]); } } diff --git a/app/Models/DataSoalModel.php b/app/Models/DataSoalModel.php index fba46b9..3267dea 100644 --- a/app/Models/DataSoalModel.php +++ b/app/Models/DataSoalModel.php @@ -33,8 +33,8 @@ protected static function boot() { parent::boot(); static::creating(function ($model) { - if (empty($model->id_lowongan_pekerjaan)) { - $model->id_lowongan_pekerjaan = Str::uuid(); + if (empty($model->id_soal)) { + $model->id_soal = Str::uuid(); } }); } diff --git a/resources/views/admin/pages/data_soal/index.blade.php b/resources/views/admin/pages/data_soal/index.blade.php index 8c3ad5e..d84d1af 100644 --- a/resources/views/admin/pages/data_soal/index.blade.php +++ b/resources/views/admin/pages/data_soal/index.blade.php @@ -58,6 +58,59 @@ + + + + + + + + + + + @endsection @section('script') @endsection \ No newline at end of file