diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 27111ff..03104f1 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Models\BookingModel; +use Carbon\Carbon; use Generator; use Illuminate\Http\Request; @@ -74,6 +75,7 @@ public function store(Request $request) ]); $kode_unik = $this->generateCode(); + $tgl_request = Carbon::parse($request->tgl_booking)->timestamp + 86399; BookingModel::create([ 'nama_lengkap' => $request->nama_lengkap, @@ -82,6 +84,7 @@ public function store(Request $request) 'tgl_booking' => $request->tgl_booking, 'deskripsi_tambahan' => $request->deskripsi_tambahan, 'kode_unik' => $kode_unik, + 'unix_expired_time' => $tgl_request ]); return response()->json([ diff --git a/app/Http/Controllers/CekStatusController.php b/app/Http/Controllers/CekStatusController.php index c80a2b9..d4221dd 100644 --- a/app/Http/Controllers/CekStatusController.php +++ b/app/Http/Controllers/CekStatusController.php @@ -38,10 +38,18 @@ public function show(string $id) { $data = BookingModel::where('kode_unik', $id)->first(); if($data != null) { - if($data->status_tes == '1' && $data->unix_expired_time < time()) { + if($data->status_tes == '1' && $data->unix_expired_time < time()) { // Lebih dari exp $data->update([ 'status_tes' => '0' ]); + } else if($data->status_tes == '1' && time() < ($data->unix_expired_time - 86399)) { // Kurang dari exp 00.00 + $data->update([ + 'status_tes' => '0' + ]); + } else if($data->status_tes == '0' && time() > ($data->unix_expired_time - 86399) && time() < ($data->unix_expired_time)) { + $data->update([ + 'status_tes' => '1' + ]); } return response()->json([ 'status' => true, @@ -51,7 +59,8 @@ public function show(string $id) 'nama_lengkap' => $data->nama_lengkap, 'kode_unik' => $data->kode_unik, 'tgl_booking' => $data->tgl_booking, - 'jam_booking' => date('H:i:s', strtotime($data->created_at)), + 'start_test' => date('H:i:s', $data->unix_expired_time - 86399), + 'end_test' => date('H:i:s', $data->unix_expired_time), 'deskripsi_tambahan' => $data->deskripsi_tambahan, ]); } else { diff --git a/app/Models/BookingModel.php b/app/Models/BookingModel.php index 1518a41..bcc5034 100644 --- a/app/Models/BookingModel.php +++ b/app/Models/BookingModel.php @@ -43,7 +43,7 @@ protected static function boot() } if(empty($model->unix_expired_time)) { - $model->unix_expired_time = (string) (time() + 86400); // Set expiration time to 24 hour from now + $model->unix_expired_time = (string) (time() + 86399); // Set expiration time to 24 hour from now } }); } diff --git a/config/app.php b/config/app.php index 423eed5..c74a68d 100644 --- a/config/app.php +++ b/config/app.php @@ -65,7 +65,7 @@ | */ - 'timezone' => 'UTC', + 'timezone' => 'Asia/Jakarta', /* |-------------------------------------------------------------------------- diff --git a/resources/views/user/layouts/index.blade.php b/resources/views/user/layouts/index.blade.php index 1c19afe..68f80a0 100644 --- a/resources/views/user/layouts/index.blade.php +++ b/resources/views/user/layouts/index.blade.php @@ -29,6 +29,7 @@ + @@ -74,6 +75,7 @@ class="bi bi-arrow-up-short"> + diff --git a/resources/views/user/pages/cek_status/index.blade.php b/resources/views/user/pages/cek_status/index.blade.php index 1d12f24..39f667b 100644 --- a/resources/views/user/pages/cek_status/index.blade.php +++ b/resources/views/user/pages/cek_status/index.blade.php @@ -58,7 +58,7 @@