Ejemplo n.º 1
0
 protected function notify(Request $request)
 {
     $this->dataRule = ['type' => 'between:1,2', 'course_id' => 'numeric'];
     if (($valid = $this->vaild_data_format($request->all(), ['type', 'course_id'])) !== true) {
         $this->responseCode = 400;
         $this->responseData['error'] = $valid;
         return $this->send_response();
     }
     $type = $request->get('type');
     $course_id = $request->get('course_id');
     $course = $this->courseRepository->getCourseById($course_id);
     $user = \Auth::user();
     $now = \Carbon\Carbon::now();
     if ($type === "1") {
         $content = "點名通知:(" . $this->weekMap[$now->format("l")] . ")" . $now->format("H:i") . " " . $user->real_name . " 在" . $course->course_nameCH . "發出了點名通知!";
     } else {
         $content = "考試通知:(" . $this->weekMap[$now->format("l")] . ")" . $now->format("H:i") . " " . $user->real_name . " 在" . $course->course_nameCH . "發出了考試通知!";
     }
     try {
         $this->facebookService->sendNotification($user, $course, $content, $type);
         $this->responseCode = 200;
         $this->responseData['status'] = "success";
     } catch (\Exception $e) {
         $this->responseCode = 403;
         $this->responseData['error'] = $e->getMessage();
     } finally {
         return $this->send_response();
     }
 }
Ejemplo n.º 2
0
 public function sendCourseNotification()
 {
     $now = Carbon::now();
     $week = $now->dayOfWeek;
     $hour = $now->hour;
     $type = "0";
     $count = 0;
     $hour2course = [6 => 'A', 7 => '1', 8 => '2', 9 => '3', 10 => '4', 11 => 'B', 12 => '5', 13 => '6', 14 => '7', 15 => '8', 16 => '9', 17 => 'C', 18 => 'D', 19 => 'E', 20 => 'F'];
     $week2course = [0 => 'Sun', 1 => 'Mon', 2 => 'Tue', 3 => 'Wed', 4 => 'Thu', 5 => 'Fri', 6 => 'Sat'];
     $courseCollect = $this->courseRepository->getCourseByTime($week2course[$week], $hour2course[$hour]);
     foreach ($courseCollect as $key => $course) {
         $content = $course->course_nameCH . " " . $this->course_start_map[$hour2course[$hour]] . " " . $course->place;
         try {
             $this->sendNotification(null, $course, $content, $type);
             $count++;
             \Log::info("[sendCourseNotification Success] " . $content);
         } catch (\Exception $e) {
             \Log::warning("[sendCourseNotification Fail] " . $content);
             \Log::warning($e->getMessage());
         }
     }
     return $count;
 }
Ejemplo n.º 3
0
 private function initCourse()
 {
     $this->courseRepository->initCourse();
 }
Ejemplo n.º 4
0
 protected function showRank()
 {
     $topLike = $this->courseRepository->getLikeTop(10);
     $topComment = $this->courseRepository->getCommentTop(10);
     $topRank = $this->courseRepository->getCurrentRankTop(10);
     $topDepartment = ['universe' => $this->courseRepository->getDepartmentTop([7], 10, 0), 'service' => $this->courseRepository->getDepartmentTop([17], 10, 0), 'cross' => $this->courseRepository->getDepartmentTop([10, 11, 12, 13, 14, 15, 16], 10, 1), 'pipe' => $this->courseRepository->getDepartmentTop([37, 38, 39, 40, 41], 10, 1), 'technology' => $this->courseRepository->getDepartmentTop([29, 30, 31, 32, 33, 34, 35, 36], 10, 1), 'science' => $this->courseRepository->getDepartmentTop([24, 25, 26, 27, 28], 10, 1), 'arts' => $this->courseRepository->getDepartmentTop([18, 19, 20, 21, 22, 23], 10, 1), 'social' => $this->courseRepository->getDepartmentTop([42, 43, 44, 45, 46, 47, 48], 10, 1), 'ocean' => $this->courseRepository->getDepartmentTop([50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60], 10, 1)];
     return view('rank', ['topLike' => $topLike, 'topComment' => $topComment, 'topRank' => $topRank, 'topDepartment' => $topDepartment]);
 }
Ejemplo n.º 5
0
 public function testGetLikeTop()
 {
     $result = $this->repository->getLikeTop(10);
 }