1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-07-02 23:16:49 +08:00
2020-05-24 20:49:55 +08:00

49 lines
1.2 KiB
PHP

<?php
namespace App\Services\Frontend\Account;
use App\Library\Validators\Common as CommonValidator;
use App\Models\Account as AccountModel;
use App\Services\Frontend\Service as FrontendService;
use App\Validators\Account as AccountValidator;
use App\Validators\Verify as VerifyValidator;
class Register extends FrontendService
{
public function handle()
{
$post = $this->request->getPost();
$verifyValidator = new VerifyValidator();
$verifyValidator->checkCode($post['account'], $post['verify_code']);
$accountValidator = new AccountValidator();
$data = [];
if (CommonValidator::phone($post['account'])) {
$data['phone'] = $accountValidator->checkPhone($post['account']);
$accountValidator->checkIfPhoneTaken($post['account']);
} elseif (CommonValidator::email($post['account'])) {
$data['email'] = $accountValidator->checkEmail($post['account']);
$accountValidator->checkIfEmailTaken($post['account']);
}
$data['password'] = $accountValidator->checkPassword($post['password']);
$account = new AccountModel();
$account->create($data);
return $account;
}
}