Commit a32e3658 by 赵增煜

增加user_id

parent c5fd1a8f
...@@ -49,24 +49,25 @@ public function add(Request $request) ...@@ -49,24 +49,25 @@ public function add(Request $request)
{ {
$data = $request->all(); $data = $request->all();
$authInfo = auth('api')->user(); $authInfo = auth('api')->user();
$patient = new PatientModel;
if ($authInfo->last_login_type == User::LOGIN_TYPE_USER) { // 用户 if ($authInfo->last_login_type == User::LOGIN_TYPE_USER) { // 用户
$data['user_id'] = $authInfo->id; $patient->user_id = $authInfo->id;
} elseif ($authInfo->last_login_type == User::LOGIN_TYPE_PHARMACY) { // 药店 } elseif ($authInfo->last_login_type == User::LOGIN_TYPE_PHARMACY) { // 药店
$pharmacy = PharmacyModel::query()->where('user_id', $authInfo->id)->first(); $pharmacy = PharmacyModel::query()->where('user_id', $authInfo->id)->first();
$data['pharmacy_id'] = $pharmacy->id; $patient->pharmacy_id = $pharmacy->id;
} }
// 验证身份证格式 // 验证身份证格式
if (! validateIdCard($data['id_card'])) { if (! validateIdCard($data['id_card'])) {
return $this->failed('身份证格式错误'); return $this->failed('身份证格式错误');
} }
$patient = new PatientModel;
$idCardInfo = Util::getIdCardInfo($data['id_card']); $idCardInfo = Util::getIdCardInfo($data['id_card']);
$patient->name = $data['name']; $patient->name = $data['name'];
$patient->id_card = $data['id_card']; $patient->id_card = $data['id_card'];
$patient->mobile = $data['mobile']; $patient->mobile = $data['mobile'];
$patient->gender = $idCardInfo['gender']; $patient->gender = $idCardInfo['gender'];
$patient->is_default = 0; $patient->is_default = 0;
# $res = PatientModel::create($data); // $res = PatientModel::create($data);
$res = $patient->save(); $res = $patient->save();
if ($res) { if ($res) {
return $this->success($res); return $this->success($res);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment