Эх сурвалжийг харах

update: add payment save request validate

tokumeikoi 3 жил өмнө
parent
commit
37a6f3861c

+ 2 - 1
app/Http/Controllers/Admin/PaymentController.php

@@ -2,6 +2,7 @@
 
 namespace App\Http\Controllers\Admin;
 
+use App\Http\Requests\Admin\PaymentSave;
 use App\Services\PaymentService;
 use App\Utils\Helper;
 use Illuminate\Http\Request;
@@ -40,7 +41,7 @@ class PaymentController extends Controller
         ]);
     }
 
-    public function save(Request $request)
+    public function save(PaymentSave $request)
     {
         if (!config('v2board.app_url')) {
             abort(500, '请在站点配置中配置站点地址');

+ 31 - 0
app/Http/Requests/Admin/PaymentSave.php

@@ -0,0 +1,31 @@
+<?php
+
+namespace App\Http\Requests\Admin;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class PaymentSave extends FormRequest
+{
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            'name' => 'required',
+            'payment' => 'required',
+            'config' => 'required'
+        ];
+    }
+
+    public function messages()
+    {
+        return [
+            'name.required' => '显示名称不能为空',
+            'payment.required' => '网关参数不能为空',
+            'config.required' => '配置参数不能为空'
+        ];
+    }
+}