isPost()) { $msgData = [ 'company_name' => trim(input('post.company_name', '')), 'name' => trim(input('post.name', '')), 'phone' => trim(input('post.phone', '')), 'email' => trim(input('post.email', '')), 'content' => trim(input('post.content', '')), ]; // 安全过滤 $msgData = array_map('strip_tags', $msgData); try { validate(VMessage::class)->check($msgData); $msgData['ip'] = request()->ip(); $msgData['create_time'] = time(); MMessage::create($msgData); return $this->json(); } catch (ValidateException $e) { return $this->json(2, $e->getError()); } } else { return $this->json(1, '非法请求'); } } }