12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- /**
- * @Name
- * @Description
- * @Author 刘学玺
- * @Date 2024/9/10 16:07
- */
- namespace App\Http\Services\Frontend\Server\Coach;
- use App\Exceptions\ApiException;
- use App\Http\Services\Service;
- use App\Models\Coach\User;
- use App\Models\Coach\Verify;
- class UserService extends Service
- {
- protected array $selectColumn = ['name', 'mobile', 'sex', 'birthday', 'work_img as workImg', 'city_id as cityId', 'status', 'verify_text as verifyText'];
- public function getUser()
- {
- // 获取用户ID
- $user_id = 1; // member_user_id
- // 获取认证信息
- $coach = Verify::query()->where('user_id', $user_id)->select($this->selectColumn)->first();
- // 判断认证信息
- return $coach ?: User::query()->where('user_id', $user_id)->select($this->selectColumn)->first();
- }
- /**
- * @throws ApiException
- */
- public function updateUser(array $data): void
- {
- // 获取用户ID
- $user_id = 1; // member_user_id
- // 获取技师ID
- $coach_id = User::query()->where('user_id', $user_id)->value('id');
- // 验证技师ID
- !$coach_id && self::error('数据错误');
- // 填充数据
- $data['user_id'] = $user_id;
- $data['coach_id'] = $coach_id;
- $data['status'] = 0;
- $data['id'] = Verify::query()->where('coach_id', $user_id)->value('id');
- self::toModel($data, Verify::class)->save();
- }
- }
|