public function resendVerify(Requests\ResetCheck $request) { $user_data = RegisterUsers::where('email', $request->get('email'))->where('pid', $request->get('pid'))->where('reg_verify', 0)->get(); if (isset($user_data[0])) { $phone = RegisterDetails::where('account_id', $user_data[0]->id)->get(); $rand = $user_data[0]->verify_code; /* Send the SMS to Users */ $date = date("YmdHis"); $pwd_file = fopen(public_path('msg_tmp/') . $date . $rand . ".txt", "a"); $content = "ccucc," . $phone[0]->phone . ",夥伴您好:驗證碼:" . $rand . "請填入系統送出註冊並填報名資訊,始完成報名。驗證網站:https://goo.gl/kfvpCT,"; $content = iconv('UTF-8', 'Big5', $content); fwrite($pwd_file, $content); fclose($pwd_file); $chk_file = fopen(public_path('msg_tmp/') . $date . $rand . ".chk", "a"); fclose($chk_file); $conn_id = ftp_connect("210.71.253.195"); $login_result = ftp_login($conn_id, "sms", "sms"); if ($login_result) { ftp_put($conn_id, $date . $rand . ".txt", public_path('msg_tmp/') . $date . $rand . ".txt", FTP_ASCII); ftp_put($conn_id, $date . $rand . ".chk", public_path('msg_tmp/') . $date . $rand . ".chk", FTP_ASCII); } $email = $user_data[0]->email; $name = $phone[0]->name; /* Send the Mail to Users */ Mail::send('emails.welcome', ['code' => $rand], function ($message) use($email, $name) { $message->from('*****@*****.**', '105偏鄉教師寒假教學專業成長研習'); $message->to($email, $name)->subject('【驗證通知信】105偏鄉教師寒假教學專業成長研習'); }); return redirect()->intended('/verify'); } else { return view('auth.reset')->with('alert_failed', true); } }
public function selectTrafficUpdate(Requests\TrafficCheck $request) { $account_details = RegisterUsers::where('email', Auth::user()->email)->get(); $habit_exist = RegisterHabits::where('account_id', $account_details[0]->id)->count(); if ($habit_exist == 1) { RegisterHabits::where('account_id', $account_details[0]->id)->update(['traffic' => $request->get('traffic')]); } else { if ($habit_exist == 0) { $input = new RegisterHabits(); $input->account_id = $account_details[0]->id; // 'Cause the variable account_id is a array. $input->traffic = $request->get('traffic'); $input->save(); } } return redirect()->intended('/general'); }
public function setPriority() { $first_day = SelectList::where('subject', '<', 20000)->get(); $second_day = SelectList::where('subject', '>', 20000)->get(); foreach ($first_day as $first_day_people) { $user_name = RegisterDetails::where('phone', $first_day_people->phone)->get(['account_id']); if (isset($user_name[0])) { if (isset($user_name[0]->account_id)) { RegisterSubjects::where('reg_subject_1', $first_day_people->subject)->where('account_id', $user_name[0]->account_id)->update(['priority' => '1']); } } $user_name = RegisterUsers::where('pid', $first_day_people->pid)->get(['id']); if (isset($user_name[0])) { if (isset($user_name[0]->account_id)) { RegisterSubjects::where('reg_subject_1', $first_day_people->subject)->where('account_id', $user_name[0]->id)->update(['priority' => '1']); } } $user_name = RegisterDetails::where('name', $first_day_people->name)->get(['account_id']); if (isset($user_name[0])) { if (isset($user_name[0]->account_id)) { RegisterSubjects::where('reg_subject_1', $first_day_people->subject)->where('account_id', $user_name[0]->account_id)->update(['priority' => '1']); } } $user_name = RegisterUsers::where('email', $first_day_people->email)->get(['id']); if (isset($user_name[0])) { if (isset($user_name[0]->id)) { RegisterSubjects::where('reg_subject_1', $first_day_people->subject)->where('account_id', $user_name[0]->id)->update(['priority' => '1']); } } } foreach ($second_day as $second_day_people) { $user_name = RegisterDetails::where('phone', $second_day_people->phone)->get(['account_id']); if (isset($user_name[0])) { if (isset($user_name[0]->account_id)) { if ($second_day_people->subject == 40005) { RegisterSubjects2::where('reg_subject_2', '>=', 20002)->where('reg_subject_2', '<=', 20003)->where('account_id', $user_name[0]->account_id)->update(['priority' => '1']); } else { RegisterSubjects2::where('reg_subject_2', $second_day_people->subject)->where('account_id', $user_name[0]->account_id)->update(['priority' => '1']); } } } $user_name = RegisterUsers::where('pid', $second_day_people->pid)->get(['id']); if (isset($user_name[0])) { if (isset($user_name[0]->id)) { if ($second_day_people->subject == 40005) { RegisterSubjects2::where('reg_subject_2', '>=', 20002)->where('reg_subject_2', '<=', 20003)->where('account_id', $user_name[0]->id)->update(['priority' => '1']); } else { RegisterSubjects2::where('reg_subject_2', $second_day_people->subject)->where('account_id', $user_name[0]->id)->update(['priority' => '1']); } } } $user_name = RegisterDetails::where('name', $second_day_people->name)->get(['account_id']); if (isset($user_name[0])) { if (isset($user_name[0]->account_id)) { if ($second_day_people->subject == 40005) { RegisterSubjects2::where('reg_subject_2', '>=', 20002)->where('reg_subject_2', '<=', 20003)->where('account_id', $user_name[0]->account_id)->update(['priority' => '1']); } else { RegisterSubjects2::where('reg_subject_2', $second_day_people->subject)->where('account_id', $user_name[0]->account_id)->update(['priority' => '1']); } } } $user_name = RegisterUsers::where('email', $second_day_people->email)->get(['id']); if (isset($user_name[0])) { if (isset($user_name[0]->id)) { if ($second_day_people->subject == 40005) { RegisterSubjects2::where('reg_subject_2', '>=', 20002)->where('reg_subject_2', '<=', 20003)->where('account_id', $user_name[0]->id)->update(['priority' => '1']); } else { RegisterSubjects2::where('reg_subject_2', $second_day_people->subject)->where('account_id', $user_name[0]->id)->update(['priority' => '1']); } } } } return 'SUCCESS'; }
public function PriorityMemberQuery() { $select_count = SelectList::all()->count(); $select_list = SelectList::all(); $count = 0; for ($i = 0; $i < $select_count; $i++) { if (isset($select_list[0]->pid)) { $count += RegisterUsers::where('pid', $select_list[0]->pid)->take(1)->count(); } elseif (isset($select_list[0]->email)) { $count += RegisterUsers::where('email', $select_list[0]->email)->take(1)->count(); } elseif (isset($select_list[0]->phone)) { $count += RegisterDetails::where('phone', $select_list[0]->phone)->take(1)->count(); } elseif (isset($select_list[0]->phone)) { $count += RegisterDetails::where('name', $select_list[0]->name)->take(1)->count(); } } }