53 lines
1.8 KiB
PHP
53 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Modules\Merchant\Http\Requests;
|
|
|
|
use Illuminate\Validation\Rule;
|
|
use Modules\Common\Http\Requests\BaseFormRequest;
|
|
|
|
class MerchantWithdrawalFormRequest extends BaseFormRequest
|
|
{
|
|
protected $stopOnFirstFailure = true;
|
|
|
|
public function rules(): array
|
|
{
|
|
if (!$this->isUpdate()) {
|
|
return [
|
|
'withdraw_no' => 'required|string|max:32|unique:merchant_withdrawals,withdraw_no',
|
|
'merchant_id' => 'required|integer',
|
|
'amount' => 'required|numeric',
|
|
'channel' => 'required|string|max:50',
|
|
'account_info' => 'required|array',
|
|
'status' => 'required|integer|in:0,1,2',
|
|
'remark' => 'nullable|string',
|
|
'processed_at' => 'nullable|date',
|
|
];
|
|
}
|
|
|
|
$id = $this->route('id');
|
|
return [
|
|
'withdraw_no' => ['required', 'string', 'max:32', Rule::unique('merchant_withdrawals', 'withdraw_no')->ignore($id)],
|
|
'merchant_id' => 'required|integer',
|
|
'amount' => 'required|numeric',
|
|
'channel' => 'required|string|max:50',
|
|
'account_info' => 'required|array',
|
|
'status' => 'required|integer|in:0,1,2',
|
|
'remark' => 'nullable|string',
|
|
'processed_at' => 'nullable|date',
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'withdraw_no.required' => '提现单号不能为空',
|
|
'withdraw_no.unique' => '提现单号已存在',
|
|
'merchant_id.required' => '商户ID不能为空',
|
|
'amount.required' => '提现金额不能为空',
|
|
'channel.required' => '提现渠道不能为空',
|
|
'account_info.required' => '账户信息不能为空',
|
|
'status.required' => '提现状态不能为空',
|
|
];
|
|
}
|
|
}
|