SmsRequest.php
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace App\Http\Container\ProviderSection\Requests;
use App\Helpers\SmsHelper;
use App\Http\Request\PhoneCodeRequest;
class SmsRequest extends PhoneCodeRequest
{
/**
* @return void
* @throws \Exception
*/
public function passedValidation(): void
{
parent::passedValidation();
$this->setCode(SmsHelper::createNumberCode(), $this->input('type'), $this->input('platform'));
}
/**
* @return string[]
*/
public function rules(): array
{
return array_merge($this->withoutRules('code'), [
'platform' => 'required|in:app,admin,manage,user',
'type' => 'required|in:login,register,changePhone',
]);
}
/**
* @return string[]
*/
public function messages(): array
{
return array_merge($this->withoutMessage('code'), [
'platform.required' => '请选择平台',
'platform.in' => '平台不在指定范围内',
'type.required' => '请选择申请场景',
'type.in' => '场景暂未开放',
]);
}
}