You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

38 lines
883 B

<?php
namespace App\Service\v3\Implementations;
use App\Constants\v3\ErrorCode;
use App\Exception\ErrorCodeException;
use App\Model\v3\User;
use App\Service\v3\Interfaces\UserBindTelServiceInterface;
class UserBindTelService implements UserBindTelServiceInterface
{
public function do($userId, $tel)
{
$user = User::find($userId);
$user->tel = $tel;
if (!$user->save()) {
throw new ErrorCodeException(ErrorCode::BIND_TEL_ERROR);
}
return true;
}
public function check($userId)
{
$user = User::find($userId);
return $user->tel ? true : false;
}
public function undo($userId)
{
$user = User::find($userId);
$user->tel = '';
if (!$user->save()) {
throw new ErrorCodeException(ErrorCode::UNBIND_TEL_ERROR);
}
return true;
}
}