isBetween($start, $end)) { return response()->json([ 'code' => 400, 'status' => 'failed', 'message' => 'Pengajuan Sudah Ditutup', ], 400); } try { $pegawai = Pegawai::where('nip', $request->nip)->orWhere('nip_siakad', $request->nip)->firstOrFail(); $kegiatanService = new KegiatanService(); $countUpdated = 0; if ($pegawai->jenis_pegawai === 'dosen') { $token = $request->bearerToken(); $data = Crypt::decrypt($token); if ($data['nip'] !== $request->nip) { throw new AuthorizationException(); } } foreach ($request->id as $id) { $syarat = Syarat::with('rubrik') ->select('id_kegiatan', 'id_kategori', 'id_rubrik', 'status_verifikasi_id') ->where('id_rubrik', 660) ->find($id); if (!$syarat) continue; if ($syarat->rubrik->syarats->where('nama', 'laporan kegiatan')->count() > 0) continue; if ($syarat->status_verifikasi_id == 1) continue; try { $kegiatanService->pengajuan($id, $request->method()); $countUpdated++; } catch (Throwable $th) { continue; } } return response()->json([ 'status' => 'success', 'code' => 200, 'message' => "Berhasil mengajukan $countUpdated kegiatan", ], 200); } catch (Throwable $th) { DB::rollBack(); Log::error("Lainnya: " . $th->getMessage()); Log::error("Lainnya: " . $request->nip); if ($th instanceof ModelNotFoundException) { return response()->json([ 'code' => 404, 'status' => 'failed', 'message' => 'Kegiatan tidak ditemukan', ], 404); } if ($th instanceof AuthorizationException) { throw new AuthorizationException(); } if ($th instanceof DecryptException) { throw new AuthorizationException(); } return response()->json([ 'code' => 500, 'status' => 'failed', 'message' => 'Server Error', ], 500); } } }