|string> */ public function rules(): array { return [ 'content' => ['required', 'string', 'max:500'], // 防止超长文本炸服 'to_user' => ['nullable', 'string', 'max:50'], 'is_secret' => ['nullable', 'boolean'], 'font_color' => ['nullable', 'string', 'max:10'], // html color hex 'action' => ['nullable', 'string', 'max:50'], // 动作(例如:微笑着说) ]; } public function messages(): array { return [ 'content.required' => '不能发送空消息。', 'content.max' => '发言内容不能超过 500 个字符。', ]; } }