47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin;
|
|
|
|
use Illuminate\Validation\Rule;
|
|
use App\Http\Requests\ApiFormRequest;
|
|
|
|
/**
|
|
* 玩家创建请求。
|
|
*
|
|
* @see AdminPlayerStoreController
|
|
*/
|
|
final class AdminPlayerStoreRequest extends ApiFormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'site_code' => ['required', 'string', 'max:64'],
|
|
'site_player_id' => ['nullable', 'string', 'max:128'],
|
|
'username' => ['nullable', 'string', 'max:128'],
|
|
'password' => ['nullable', 'string', 'min:6', 'max:128'],
|
|
'nickname' => ['nullable', 'string', 'max:128'],
|
|
'default_currency' => ['sometimes', 'string', 'max:16', Rule::exists('currencies', 'code')],
|
|
'status' => ['sometimes', 'integer', 'in:0,1,2'],
|
|
'agent_node_id' => ['sometimes', 'nullable', 'integer', 'min:1'],
|
|
'credit_limit' => ['sometimes', 'integer', 'min:0'],
|
|
'rebate_rate' => ['sometimes', 'numeric', 'min:0', 'max:100'],
|
|
'extra_rebate_rate' => ['sometimes', 'numeric', 'min:0', 'max:100'],
|
|
];
|
|
}
|
|
|
|
protected function prepareForValidation(): void
|
|
{
|
|
if (! $this->has('default_currency')) {
|
|
return;
|
|
}
|
|
|
|
$code = strtoupper(substr(trim((string) $this->input('default_currency')), 0, 16));
|
|
$this->merge(['default_currency' => $code]);
|
|
}
|
|
}
|