diff --git a/app/Http/Controllers/CekStatusController.php b/app/Http/Controllers/CekStatusController.php index f33837d..3871ac6 100644 --- a/app/Http/Controllers/CekStatusController.php +++ b/app/Http/Controllers/CekStatusController.php @@ -41,6 +41,7 @@ public function show(string $id) return response()->json([ 'status' => true, 'msg' => 'Data ditemukan (' . $id . ')', + 'id_booking' => $data->id_booking, 'status_data' => $data->status_tes, 'nama_lengkap' => $data->nama_lengkap, 'kode_unik' => $data->kode_unik, diff --git a/app/Http/Controllers/TestSessionsController.php b/app/Http/Controllers/TestSessionsController.php new file mode 100644 index 0000000..325981d --- /dev/null +++ b/app/Http/Controllers/TestSessionsController.php @@ -0,0 +1,88 @@ +validate([ + 'id_booking' => 'required|exists:booking,id_booking', + ]); + + $testSession = TestSessionsModel::create([ + 'id_booking' => $request->id_booking, + 'status_session' => 0, // Set status awal sebagai "Belum Dimulai" + ]); + + return redirect()->route('cek-status.show', $request->id_booking)->with('success', 'Sesi tes berhasil dibuat. Token: ' . $testSession->token_session); + } + + /** + * Display the specified resource. + */ + public function show(string $id) + { + $data = TestSessionsModel::where('id_booking', $id)->first(); + if($data != null) { + return response()->json([ + 'status' => true, + 'msg' => 'Data ditemukan (' . $id . ')', + 'status_session' => $data->status_session, + 'token_session' => $data->token_session, + 'id_booking' => $data->id_booking, + ]); + + } + return response()->json([ + 'status' => false, + 'msg' => 'Data tidak ditemukan (' . $id . ')', + ]); + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(string $id) + { + // + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, string $id) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(string $id) + { + // + } +} diff --git a/app/Models/BookingModel.php b/app/Models/BookingModel.php index beb7df8..5856df0 100644 --- a/app/Models/BookingModel.php +++ b/app/Models/BookingModel.php @@ -38,7 +38,7 @@ protected static function boot() } if(empty($model->status_tes)) { - $model->status_tes = 0; + $model->status_tes = '0'; } }); } diff --git a/app/Models/TestSessionsModel.php b/app/Models/TestSessionsModel.php new file mode 100644 index 0000000..e711429 --- /dev/null +++ b/app/Models/TestSessionsModel.php @@ -0,0 +1,42 @@ + 'string', + 'id_booking' => 'string', + ]; + + protected static function boot() + { + parent::boot(); + static::creating(function ($model) { + if (empty($model->id_test_sessions)) { + $model->id_test_sessions = (string) \Illuminate\Support\Str::uuid(); + } + + if (empty($model->token_session)) { + $model->token_session = \Illuminate\Support\Str::random(50); + } + }); + } +} + diff --git a/database/migrations/2026_04_02_165234_create_test_sessions_table.php b/database/migrations/2026_04_02_165234_create_test_sessions_table.php index bbf8767..d93dae7 100644 --- a/database/migrations/2026_04_02_165234_create_test_sessions_table.php +++ b/database/migrations/2026_04_02_165234_create_test_sessions_table.php @@ -14,7 +14,7 @@ public function up(): void Schema::create('test_sessions', function (Blueprint $table) { $table->uuid('id_test_sessions')->primary(); $table->enum('status_session', [0, 1, 2]); - $table->string(); + $table->string('token_session', 50)->unique(); $table->uuid('id_booking'); $table->timestamps(); diff --git a/resources/views/user/pages/cek_status/index.blade.php b/resources/views/user/pages/cek_status/index.blade.php index cd710c9..ab1f36c 100644 --- a/resources/views/user/pages/cek_status/index.blade.php +++ b/resources/views/user/pages/cek_status/index.blade.php @@ -71,18 +71,25 @@ -