isPost()) { // 提交留言处理 $form_data = request()->post([ 'name', 'email', 'content' ]); // 数据校验 $validate = new ContactUsValidate; if (!$validate->check($form_data)) { return error($validate->getError()); } // 保存留言 $msg = LeaveMessageModel::create([ 'language_id' => $this->lang_id, 'name' => $form_data['name'], 'email' => $form_data['email'], 'content' => $form_data['content'], 'ip' => request()->ip(), 'user_agent' => request()->header('user-agent'), ]); if ($msg->isEmpty()) { return error(lang('contact_message.send_fail')); } return success(lang('contact_message.send_success')); } $focus_image = []; $our_information = []; // 获取我的信息banner $banner = SysBannerModel::with(['items' => function($query) { $query->withoutField(['status', 'created_at', 'updated_at', 'deleted_at']) ->where('status', '=', 1) ->order(['sort' => 'asc', 'id' => 'desc']); }]) ->uniqueLabel([ 'BANNER_6801be1e7d686', 'BANNER_6801c053ce12e', ]) ->language($this->lang_id) ->enabled(true) ->select(); if (!$banner->isEmpty()) { $banner_map = []; foreach ($banner as $v) { $banner_map[$v->unique_label] = $v; } $focus_image = data_get($banner_map, 'BANNER_6801be1e7d686')?->items->first()?->toArray(); $our_information = data_get($banner_map, 'BANNER_6801c053ce12e')?->items->toArray(); } View::assign('focus_image', $focus_image); View::assign('our_information', $our_information); return View::fetch('message'); } /** * 留言成为分销商 */ public function distributor() { if (request()->isPost()) { // 提交留言处理 } return View::fetch('distributor'); } }