feat: 增强环境配置与开发服务,支持局域网访问及币种管理
This commit is contained in:
34
app/Http/Requests/Admin/AdminCurrencyStoreRequest.php
Normal file
34
app/Http/Requests/Admin/AdminCurrencyStoreRequest.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
final class AdminCurrencyStoreRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'code' => ['required', 'string', 'max:16', 'regex:/^[A-Z0-9]{1,16}$/', Rule::unique('currencies', 'code')],
|
||||
'name' => ['required', 'string', 'max:64'],
|
||||
'decimal_places' => ['sometimes', 'integer', 'min:0', 'max:12'],
|
||||
'is_enabled' => ['sometimes', 'boolean'],
|
||||
'is_bettable' => ['sometimes', 'boolean'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
if ($this->has('code')) {
|
||||
$this->merge([
|
||||
'code' => strtoupper(substr(trim((string) $this->input('code')), 0, 16)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user