| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace App\Http\Requests\WorkOrder;
- use App\Traits\RequestApiFormValidation;
- use Illuminate\Foundation\Http\FormRequest;
- use Illuminate\Support\Facades\Route;
- class WorkOrderRequest extends FormRequest
- {
- use RequestApiFormValidation;
- /**
- * Determine if the user is authorized to make this request.
- *
- * @return bool
- */
- public function authorize()
- {
- return true;
- }
- /**
- * Get the validation rules that apply to the request.
- *
- * @return array
- */
- public function rules()
- {
- $routeName = Route::currentRouteName();
- switch ($routeName ){
- case 'workOrder.damagedApi':
- return $this->damagedApiRule();
- case 'worKOrder.workOrder.interceptApi':
- return $this->interceptApiRule();
- default:
- return [];
- }
- }
- public function messages(): array
- {
- $routeName = Route::currentRouteName();
- switch ($routeName ){
- case 'workOrder.damagedApi':
- return $this->damagedApiMessage();
- case 'worKOrder.workOrder.interceptApi':
- return $this->interceptApiMessage();
- default:
- return [];
- }
- }
- public function damagedApiRule(): array
- {
- return [
- 'order_no' => 'required|string',
- 'packageImages' => 'required|array',
- 'commodityImages' => 'required|array',
- 'dealImages' => 'required|array',
- ];
- }
- public function damagedApiMessage(): array
- {
- return [
- 'order_no.required' => '未指定订单',
- 'order_no.string' => '订单数据格式不正确',
- 'packageImages.required' => '未上传外包装图片',
- 'packageImages.array' => '外包装图片按数组格式上传',
- 'commodityImages.required' => '未上传内物图片',
- 'commodityImages.array' => '内物图片按数组格式上传',
- 'dealImages.required' => '未上传交易图片',
- 'dealImages.array' => '交易图片按数组格式上传',
- ];
- }
- public function interceptApiRule():array
- {
- return [
- 'orderNos' => 'required|array',
- 'remark' => 'string',
- ];
- }
- public function interceptApiMessage(): array
- {
- return [
- 'orderNos.required' => '参数异常',
- 'orderNos.array' => '参数异常',
- 'remark.string' => '参数异常',
- ];
- }
- }
|