pushCriteria(app(RequestCriteria::class)); } /** * @param $account string * @return null|Member */ public function getMemberByAccount($account) { if (validator_check($account, 'email')) { return $this->model->where('email', $account)->first(); } if (validator_check($account, new MobileRule())) { return $this->model->where('mobile', $account)->first(); } if (isCreditNo($account)) { $member_info = MemberInfo::where('id_card', $account)->first(); if (!$member_info) { return null; } return $member_info->members; } return $this->model->where('username', $account)->first(); } /** * @param $id * @return object */ public function getMemberById($id) { return $this->model->find($id); } public function updatePasswordById($password, $id) { return $this->model->where(['id'=>$id])->update(['password'=>$password]); } public function getFields($id, $field = ['*']) { return $this->model->where('id', $id)->select($field)->first(); } public function updateInfo($id, $date) { return $this->model->where('id', $id)->update($date); } public function updateLoginStatus($member) { $member->last_login_ip=ip2long(request()->ip); $member->last_login_time=time(); $member->save(); } /** * 检查字段惟一 * @param $key * @param $value * @param int $id 大于0表示排除自身 * @return bool */ public function checkUniaue($key, $value, $id = 0) { if (!Schema::hasColumn($this->model->getTable(), $key)) { return true; } if ($this->model->withTrashed()->where($key, $value) ->when($id>0, function ($query) use ($id) { return $query->where('id', '<>', $id); })->first()) { return false; } return true; } /** * 重置密码 * @param $type :mobile, email * @param $value :对应type * @param $password */ public function resetPassword($type, $value, $password) { $this->model->where($type, $value)->update(['password'=>Hash::make($password)]); } public function getLastPersonCount($where) { return $this->model->where($where)->where('created_at', '>=', date('Y-m-01 00:00:00', strtotime('-1 month')))->where('created_at', '<=', date("Y-m-d 23:59:59", strtotime(-date('d').'day')))->count(); } public function getNextPersonCount($where) { return $this->model->where($where)->where('created_at', '>=', date('Y-m-01 00:00:00', strtotime(date("Y-m-d"))))->where('created_at', '<=', date('Y-m-d 23:59:59', strtotime(date('Y-m-01', strtotime(date("Y-m-d")))." +1 month -1 day")))->count(); } public function getPersonCount($where) { return $this->model->where($where)->count(); } public function getMemberNumByTime($where, $time_condition) { return $this->model->where($where)->where(function ($query) use ($time_condition) { if ($time_condition) { $query->Where([['last_login_time', '>=',strtotime($time_condition[0])],['last_login_time', '<=',strtotime($time_condition[1])]])->orWhere([['updated_at', '>=',strtotime($time_condition[0])],['updated_at', '<=',strtotime($time_condition[1])]]); } })->count(); } public function getJobSeekersByGroup($where, $where_str, $fields, $group_by) { return DB::table(Resume::getTableName().' as r') ->select(DB::raw($fields)) ->leftjoin(MemberInfo::getTableName().' as mi', 'mi.uid', '=', 'r.uid') ->leftjoin(Member::getTableName().' as m', 'm.id', '=', 'mi.uid') ->where($where) ->whereRaw($where_str) ->groupBy($group_by) ->get(); } }