/**
  * 获取搜索结果
  * @method getRsearchResult
  * @param  Request          $request [description]
  * @return [type]                    [description]
  */
 public function getRsearchResult(Request $request)
 {
     $keyword = $request->get('keyword', '');
     $province = $request->get('province', '');
     $teacher = $request->get('teacher', '');
     $result = TrainingTeacher::select('id', 'name', 'cell_phone', 'email', 'invite_code', 'payment_account', 'invite_code_status');
     if (!empty($keyword)) {
         $result->where('name', 'like', "%{$keyword}%")->orWhere('subbranch', 'like', "%{$keyword}%");
     }
     if (!empty($province)) {
         $result->where('province', $province);
     }
     if (!empty($teacher)) {
         $result->where('name', $teacher);
     }
     $result = $result->paginate(15)->appends(['keyword' => $keyword, 'province' => $province, 'teacher' => $teacher]);
     return view('teach_invite_codes')->with(['result' => $result])->withInput($request->all());
 }
 /**
  * 获取邀请码
  * @method getInviteCode
  * @return [type]        [description]
  */
 public function getInviteCode()
 {
     // 获取邀请码
     $invite_code = self::generateInviteCode();
     // 校验邀请码是否已被使用
     $org_invite_codes = TrainingTeacher::select('invite_code')->get();
     $teach_invite_codes = TrainingInstitution::select('invite_code')->get();
     foreach ($org_invite_codes as $value) {
         $codes[] = $value->invite_code;
     }
     foreach ($teach_invite_codes as $value) {
         $codes[] = $value->invite_code;
     }
     while (in_array($invite_code, $codes)) {
         $invite_code = self::generateInviteCode();
     }
     $data = ['invite_code' => $invite_code];
     return $data;
 }