/** * 获取邀请码 * @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; }
/** * 更新单个机构的信息 * @method updateInsInfo * @param TrainingTeacher $id [description] * @return [type] [description] */ public function updateInsInfo(TrainingTeacher $id, Request $request) { $id->name = $request->teacher_name; $id->cell_phone = $request->cell_phone; $id->email = $request->email; $id->save(); return redirect($_SERVER['HTTP_REFERER']); }