示例#1
0
 public function Index()
 {
     $settings_value = Settings::all();
     $expiresAt = Carbon::now()->addMinutes(10);
     if (Cache::has('TimeControlling')) {
         $previous_renew_time = Cache::get('TimeControlling');
         $diffMinutes = $previous_renew_time->diffInMinutes();
         if ($diffMinutes >= 10) {
             Cache::put('TimeControlling', Carbon::now(), $expiresAt);
         }
     } else {
         Cache::add('TimeControlling', Carbon::now(), $expiresAt);
         $diffMinutes = 0;
     }
     $subject_list_1 = SubjectList::where('subject_id', '<', 20000)->get();
     for ($i = 0; $i < 9; $i++) {
         if (Cache::has($subject_list_1[$i]->subject_id)) {
             if ($diffMinutes >= 10) {
                 Cache::put($subject_list_1[$i]->subject_id, RegisterSubjects::where('reg_subject_1', $subject_list_1[$i]->subject_id)->count(), $expiresAt);
             }
             $subject_count_1[$subject_list_1[$i]->subject_id] = Cache::get($subject_list_1[$i]->subject_id, '請重新整理一次');
         } else {
             Cache::add($subject_list_1[$i]->subject_id, RegisterSubjects::where('reg_subject_1', $subject_list_1[$i]->subject_id)->count(), $expiresAt);
             $subject_count_1[$subject_list_1[$i]->subject_id] = Cache::get($subject_list_1[$i]->subject_id, '請重新整理一次');
         }
     }
     $subject_list_2 = SubjectList::where('subject_id', '>', 20000)->get();
     for ($i = 0; $i < 5; $i++) {
         if (Cache::has($subject_list_2[$i]->subject_id)) {
             if ($diffMinutes >= 10) {
                 Cache::put($subject_list_2[$i]->subject_id, RegisterSubjects2::where('reg_subject_2', $subject_list_2[$i]->subject_id)->count(), $expiresAt);
             }
             $subject_count_2[$subject_list_2[$i]->subject_id] = Cache::get($subject_list_2[$i]->subject_id, '請重新整理一次');
         } else {
             Cache::add($subject_list_2[$i]->subject_id, RegisterSubjects2::where('reg_subject_2', $subject_list_2[$i]->subject_id)->count(), $expiresAt);
             $subject_count_2[$subject_list_2[$i]->subject_id] = Cache::get($subject_list_2[$i]->subject_id, '請重新整理一次');
         }
     }
     return view('index', compact('subject_list_1', 'subject_list_2', 'subject_count_1', 'subject_count_2', 'settings_value'));
 }
示例#2
0
 public function startup()
 {
     parent::startup();
     $this->template->setting = $this->setting = $this->settings->findAllByKeys();
     $this->template->wfont = $this->getHttpRequest()->getCookie('wfont');
 }
示例#3
0
 public function selectSubjectUpdate(Requests\SelectSubjectCheck $request)
 {
     $settings_value = Settings::all();
     if ($settings_value[0]->value > Carbon::now() && $settings_value[1]->value < Carbon::now()) {
         return view('errors.RegisterInValid');
     }
     $account_details = RegisterUsers::where('email', Auth::user()->email)->get();
     $first_day_data_exist = RegisterSubjects::where('account_id', $account_details[0]->id)->count();
     $second_day_data_exist = RegisterSubjects2::where('account_id', $account_details[0]->id)->count();
     /* If User Doesn't Select the Subject, the Data Would Not Be Saved */
     /* If User Has Filled the Form Before, We Will Update the Previous Data */
     /* First Day Registration Data */
     if ($first_day_data_exist == 1) {
         if ($request->get('reg_subject_1') != 0) {
             RegisterSubjects::where('account_id', $account_details[0]->id)->update(['reg_subject_1' => $request->get('reg_subject_1')]);
         } else {
             RegisterSubjects::where('account_id', $account_details[0]->id)->delete();
         }
     } else {
         if ($first_day_data_exist == 0 && $request->get('reg_subject_1')) {
             $input = new RegisterSubjects();
             $input->account_id = $account_details[0]->id;
             // 'Cause the variable account_id is a array.
             $input->reg_subject_1 = $request->get('reg_subject_1');
             $input->already_pick_1 = 0;
             $input->ps = 'NORMAL';
             $input->priority = 0;
             $input->reg_time = Carbon::Now();
             $input->save();
         }
     }
     /* If User Doesn't Select the Subject, the Data Would Not Be Saved */
     /* If User Has Filled the Form Before, We Will Update the Previous Data */
     /* Second Day Registration Data */
     if ($second_day_data_exist == 1) {
         if ($request->get('reg_subject_2') != 0) {
             RegisterSubjects2::where('account_id', $account_details[0]->id)->update(['reg_subject_2' => $request->get('reg_subject_2')]);
         } else {
             RegisterSubjects2::where('account_id', $account_details[0]->id)->delete();
         }
     } else {
         if ($second_day_data_exist == 0 && $request->get('reg_subject_2')) {
             $input = new RegisterSubjects2();
             $input->account_id = $account_details[0]->id;
             // 'Cause the variable account_id is a array.
             $input->reg_subject_2 = $request->get('reg_subject_2');
             $input->already_pick_2 = 0;
             $input->ps = 'NORMAL';
             $input->priority = 0;
             $input->reg_time = Carbon::Now();
             $input->save();
         }
     }
     $user_habits_exist = RegisterHabits::where('account_id', $account_details[0]->id)->count();
     if ($user_habits_exist) {
         return redirect()->intended('/general');
     } else {
         return redirect()->intended('/general/select-habits');
     }
 }
示例#4
0
 public function OldMemberQuery()
 {
     $reg_start = Settings::where('id', 1)->get();
     $user_details = RegisterUsers::where('reg_time', '<', $reg_start[0]->value)->get();
     return view('console.old-member-query', compact('user_details'));
 }