ChangePhoneRequest.php
855 Bytes
<?php
namespace App\Http\Container\AppSection\Requests;
use App\Http\Request\PhoneCodeRequest;
use App\Support\BusinessCode;
use Hikoon\LaravelApi\Exceptions\ValidationException;
class ChangePhoneRequest extends PhoneCodeRequest
{
    /**
     * @var string
     */
    protected string $areaName = 'area_code';
    /**
     * @return void
     * @throws \Hikoon\LaravelApi\Exceptions\ValidationException
     * @throws \RedisException
     */
    public function passedValidation(): void
    {
        parent::passedValidation();
        $this->setCode($this->input('code'), 'changePhone', 'app');
        if ($this->checkPhoneExist()) {
            throw new ValidationException(BusinessCode::PHONE_EXISTS);
        }
        if (!$this->checkSmsKey()) {
            throw new ValidationException(BusinessCode::SMS_CODE_ERROR);
        }
    }
}