39 lines
745 B
PHP
39 lines
745 B
PHP
<?php
|
|
/**
|
|
* This service file is part of item.
|
|
*
|
|
* @author ctexthuang
|
|
* @contact ctexthuang@qq.com
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Service\Api\User;
|
|
|
|
use App\Exception\ErrException;
|
|
use App\Model\User;
|
|
use App\Service\Api\BaseService;
|
|
|
|
class UnBindPhoneService extends BaseService
|
|
{
|
|
/**
|
|
* @var User
|
|
*/
|
|
protected User $userModel;
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function handle()
|
|
{
|
|
$userInfo = $this->userModel->find($this->userId);
|
|
|
|
if ($userInfo->isEmpty()) throw new ErrException('用户不存在');
|
|
|
|
$userInfo->phone = '';
|
|
|
|
if (!$userInfo->save()) throw new ErrException('解绑失败');
|
|
|
|
return $this->return->success('解绑成功');
|
|
}
|
|
} |