Esempio n. 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'));
 }
Esempio n. 2
0
 public function NoticeSend()
 {
     $list_first_day = RegisterSubjects::where('already_pick_1', 1)->get();
     $list_second_day = RegisterSubjects2::where('already_pick_2', 1)->get();
     foreach ($list_first_day as $list_first_days) {
         echo $list_first_days->details->users->email;
         $rand = rand(100000, 999999);
         $email = $list_first_days->details->users->email;
         $name = $list_first_days->details->name;
         Mail::send('emails.notice', ['code' => $rand], function ($message) use($email, $name) {
             $message->from('*****@*****.**', '105偏鄉教師寒假教學專業成長研習');
             $message->to($email, $name)->subject('【重要通知】105全國偏鄉教師寒假教學專業成長研習行前通知');
         });
     }
     foreach ($list_second_day as $list_second_days) {
         echo $list_second_days->details->users->email;
         $rand = rand(1000000, 9999999);
         $email = $list_second_days->details->users->email;
         $name = $list_second_days->details->name;
         Mail::send('emails.notice', ['code' => $rand], function ($message) use($email, $name) {
             $message->from('*****@*****.**', '105偏鄉教師寒假教學專業成長研習');
             $message->to($email, $name)->subject('【重要通知】105全國偏鄉教師寒假教學專業成長研習行前通知');
         });
     }
     //$all_list = RegisterUsers::all();
     return 'SUCCESS';
 }
Esempio n. 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');
     }
 }
Esempio n. 4
0
 public function MemberExchange(Requests\ExchangeCheck $request)
 {
     if ($request->properties) {
         if ($request->subject_id < 20000) {
             if ($request->reg_num != '') {
                 $final_count = $request->reg_num;
             } else {
                 $final_count = RegisterSubjects::where('reg_subject_1', $request->subject_id)->orderBy('stu_id', 'DESC')->take(1)->get();
                 $prefix = substr($final_count[0]->stu_id, 0, 1);
                 $final_count = substr($final_count[0]->stu_id, 1, 3);
                 $final_count = str_pad($final_count, 3, '0', STR_PAD_LEFT);
                 $final_count = $prefix . ++$final_count;
             }
             RegisterSubjects::where('account_id', $request->account_id)->update(['already_pick_1' => 1, 'stu_id' => $final_count, 'ps' => 'SECONDARY']);
             if ($request->exchange_id != '') {
                 RegisterSubjects::where('account_id', $request->exchange_id)->update(['already_pick_1' => 0, 'stu_id' => '', 'ps' => 'NORMAL']);
             }
         } elseif ($request->subject_id > 20000) {
             if ($request->reg_num != '') {
                 $final_count = $request->reg_num;
             } else {
                 $final_count = RegisterSubjects2::where('reg_subject_2', $request->subject_id)->orderBy('stu_id', 'DESC')->take(1)->get();
                 $prefix = substr($final_count[0]->stu_id, 0, 1);
                 $final_count = substr($final_count[0]->stu_id, 1, 3);
                 $final_count = str_pad($final_count, 3, '0', STR_PAD_LEFT);
                 $final_count = $prefix . ++$final_count;
             }
             RegisterSubjects2::where('account_id', $request->account_id)->update(['already_pick_2' => 1, 'stu_id' => $final_count, 'ps' => 'SECONDARY']);
             if ($request->exchange_id != '') {
                 RegisterSubjects2::where('account_id', $request->exchange_id)->update(['already_pick_2' => 0, 'stu_id' => '', 'ps' => 'NORMAL']);
             }
         }
     } else {
         if ($request->subject_id < 20000) {
             if ($request->reg_num != '') {
                 $final_count = $request->reg_num;
             } else {
                 $final_count = RegisterSubjects::where('reg_subject_1', $request->subject_id)->orderBy('stu_id', 'DESC')->take(1)->get();
                 $prefix = substr($final_count[0]->stu_id, 0, 1);
                 $final_count = substr($final_count[0]->stu_id, 1, 3);
                 $final_count = str_pad($final_count, 3, '0', STR_PAD_LEFT);
                 $final_count = $prefix . ++$final_count;
             }
             RegisterSubjects::where('account_id', $request->account_id)->update(['already_pick_1' => 0, 'stu_id' => '', 'ps' => 'NORMAL']);
             if ($request->exchange_id != '') {
                 RegisterSubjects::where('account_id', $request->exchange_id)->update(['already_pick_1' => 1, 'stu_id' => $final_count, 'ps' => 'SECONDARY']);
             }
         } elseif ($request->subject_id > 20000) {
             if ($request->reg_num != '') {
                 $final_count = $request->reg_num;
             } else {
                 $final_count = RegisterSubjects2::where('reg_subject_2', $request->subject_id)->orderBy('stu_id', 'DESC')->take(1)->get();
                 $prefix = substr($final_count[0]->stu_id, 0, 1);
                 $final_count = substr($final_count[0]->stu_id, 1, 3);
                 $final_count = str_pad($final_count, 3, '0', STR_PAD_LEFT);
                 $final_count = $prefix . ++$final_count;
             }
             RegisterSubjects2::where('account_id', $request->account_id)->update(['already_pick_2' => 0, 'stu_id' => '', 'ps' => 'NORMAL']);
             if ($request->exchange_id != '') {
                 RegisterSubjects2::where('account_id', $request->exchange_id)->update(['already_pick_2' => 1, 'stu_id' => $final_count, 'ps' => 'SECONDARY']);
             }
         }
     }
     return redirect('/console/member-query/' . $request->subject_id);
 }