mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 09:21:46 +08:00 
			
		
		
		
	opt
This commit is contained in:
		| @@ -21,25 +21,24 @@ class PlanController extends Controller | ||||
|  | ||||
|     public function save(PlanSave $request) | ||||
|     { | ||||
|         $params = $request->only(array_keys(PlanSave::RULES)); | ||||
|         if ($request->input('id')) { | ||||
|             $plan = Plan::find($request->input('id')); | ||||
|             if (!$plan) { | ||||
|                 abort(500, '该订阅不存在'); | ||||
|             } | ||||
|         } else { | ||||
|             $plan = new Plan(); | ||||
|             if (!$plan->update($params)) { | ||||
|                 abort(500, '保存失败'); | ||||
|             } | ||||
|             return response([ | ||||
|                 'data' => true | ||||
|             ]); | ||||
|         } | ||||
|         if (!Plan::create($params)) { | ||||
|             abort(500, '创建失败'); | ||||
|         } | ||||
|         $plan->name = $request->input('name'); | ||||
|         $plan->content = $request->input('content'); | ||||
|         $plan->transfer_enable = $request->input('transfer_enable'); | ||||
|         $plan->group_id = $request->input('group_id'); | ||||
|         $plan->month_price = $request->input('month_price'); | ||||
|         $plan->quarter_price = $request->input('quarter_price'); | ||||
|         $plan->half_year_price = $request->input('half_year_price'); | ||||
|         $plan->year_price = $request->input('year_price'); | ||||
|  | ||||
|         return response([ | ||||
|             'data' => $plan->save() | ||||
|             'data' => true | ||||
|         ]); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -6,6 +6,16 @@ use Illuminate\Foundation\Http\FormRequest; | ||||
|  | ||||
| class PlanSave extends FormRequest | ||||
| { | ||||
|     CONST RULES = [ | ||||
|         'name' => 'required', | ||||
|         'content' => '', | ||||
|         'group_id' => 'required', | ||||
|         'transfer_enable' => 'required', | ||||
|         'month_price' => 'nullable|integer', | ||||
|         'quarter_price' => 'nullable|integer', | ||||
|         'half_year_price' => 'nullable|integer', | ||||
|         'year_price' => 'nullable|integer' | ||||
|     ]; | ||||
|     /** | ||||
|      * Get the validation rules that apply to the request. | ||||
|      * | ||||
| @@ -13,15 +23,7 @@ class PlanSave extends FormRequest | ||||
|      */ | ||||
|     public function rules() | ||||
|     { | ||||
|         return [ | ||||
|             'name' => 'required', | ||||
|             'group_id' => 'required', | ||||
|             'transfer_enable' => 'required', | ||||
|             'month_price' => 'nullable|integer', | ||||
|             'quarter_price' => 'nullable|integer', | ||||
|             'half_year_price' => 'nullable|integer', | ||||
|             'year_price' => 'nullable|integer' | ||||
|         ]; | ||||
|         return self::RULES; | ||||
|     } | ||||
|  | ||||
|     public function messages() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user