isUpdate()) { return [ 'order_no' => 'required|string|max:50|unique:task_orders,order_no', 'user_id' => 'required|integer', 'runner_id' => 'nullable|integer', 'category_id' => 'required|integer', 'title' => 'required|string|max:255', 'description' => 'nullable|string', 'images' => 'nullable|json', 'extra' => 'nullable|json', 'price' => 'nullable|numeric|min:0', 'address' => 'nullable|string|max:255', 'contact_name' => 'required|string|max:50', 'contact_mobile' => 'required|string|max:20', 'deadline' => 'nullable|date', 'pay_type' => 'nullable|integer|in:0,1,2', 'pay_status' => 'nullable|integer|in:0,1,2', 'paid_at' => 'nullable|date', 'status' => 'nullable|integer|in:0,1,2,3,4,5', 'cancel_reason' => 'nullable|string|max:255', 'remark' => 'nullable|string|max:255', 'accepted_at' => 'nullable|date', 'completed_at' => 'nullable|date', 'cancelled_at' => 'nullable|date', ]; } $id = $this->route('id'); return [ 'order_no' => [ 'required', 'string', 'max:50', Rule::unique('task_orders', 'order_no')->ignore($id), ], 'user_id' => 'required|integer', 'runner_id' => 'nullable|integer', 'category_id' => 'required|integer', 'title' => 'required|string|max:255', 'description' => 'nullable|string', 'images' => 'nullable|json', 'extra' => 'nullable|json', 'price' => 'nullable|numeric|min:0', 'address' => 'nullable|string|max:255', 'contact_name' => 'required|string|max:50', 'contact_mobile' => 'required|string|max:20', 'deadline' => 'nullable|date', 'pay_type' => 'nullable|integer|in:0,1,2', 'pay_status' => 'nullable|integer|in:0,1,2', 'paid_at' => 'nullable|date', 'status' => 'nullable|integer|in:0,1,2,3,4,5', 'cancel_reason' => 'nullable|string|max:255', 'remark' => 'nullable|string|max:255', 'accepted_at' => 'nullable|date', 'completed_at' => 'nullable|date', 'cancelled_at' => 'nullable|date', ]; } public function messages(): array { return [ 'order_no.required' => '订单号不能为空', 'order_no.unique' => '订单号已存在', 'user_id.required' => '用户不能为空', 'category_id.required' => '分类不能为空', 'title.required' => '标题不能为空', 'contact_name.required' => '联系人不能为空', 'contact_mobile.required' => '联系电话不能为空', ]; } }