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
887 B
38 lines
887 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\UserBindServiceInterface;
|
|
|
|
class UserBindService implements UserBindServiceInterface
|
|
{
|
|
|
|
public function makeTel($userId, $tel)
|
|
{
|
|
$user = User::find($userId);
|
|
$user->tel = $tel;
|
|
if (!$user->save()) {
|
|
throw new ErrorCodeException(ErrorCode::BIND_TEL_ERROR);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public function checkTel($userId)
|
|
{
|
|
$user = User::find($userId);
|
|
return $user->tel ? true : false;
|
|
}
|
|
|
|
public function removeTel($userId)
|
|
{
|
|
$user = User::find($userId);
|
|
$user->tel = '';
|
|
if (!$user->save()) {
|
|
throw new ErrorCodeException(ErrorCode::UNBIND_TEL_ERROR);
|
|
}
|
|
return true;
|
|
}
|
|
}
|