$params['create_user_id'], 'user_id' => $params['user_id'], 'area_id' => $params['area_id'], 'street_id' => $params['street_id'], 'village_id' => $params['village_id'], 'brigade_id' => $params['brigade_id'], 'address' => $params['address'], 'name' => $params['name'], 'phone' => $params['phone'], 'sex' => $params['sex'], 'age' => $params['age'], 'wechat' => $params['wechat'], 'family' => $params['family'], 'child' => $params['child'], 'child_arr' => $params['child_arr'], 'highway' => $params['highway'], 'smart_phone' => $params['smart_phone'], 'status' => $params['status'] ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 编辑 * @param array $params * @return bool * @author likeadmin * @date 2023/08/01 15:00 */ public static function edit(array $params): bool { Db::startTrans(); try { UserInformationg::where('id', $params['id'])->update([ 'create_user_id' => $params['create_user_id'], 'user_id' => $params['user_id'], 'area_id' => $params['area_id'], 'street_id' => $params['street_id'], 'village_id' => $params['village_id'], 'brigade_id' => $params['brigade_id'], 'address' => $params['address'], 'name' => $params['name'], 'phone' => $params['phone'], 'sex' => $params['sex'], 'age' => $params['age'], 'wechat' => $params['wechat'], 'family' => $params['family'], 'child' => $params['child'], 'child_arr' => $params['child_arr'], 'highway' => $params['highway'], 'smart_phone' => $params['smart_phone'], 'status' => $params['status'] ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 删除 * @param array $params * @return bool * @author likeadmin * @date 2023/08/01 15:00 */ public static function delete(array $params): bool { return UserInformationg::destroy($params['id']); } /** * @notes 获取详情 * @param $params * @return array * @author likeadmin * @date 2023/08/01 15:00 */ public static function detail($params): array { $item = UserInformationg::where('id', $params['id'])->field('*,area_id area_name,street_id street_name,village_id village_name,brigade_id brigade_name')->find(); $item['family'] = json_decode($item['family'], true); $item['child_arr'] = json_decode($item['child_arr'], true); $data = UserInformationgDemand::where('information_id', $params['id'])->order('id', 'desc')->select(); $item['datas'] = []; $datas = []; if ($data) { foreach ($data as $k => $v) { $a = $v['data']; // json_decode($v['data'], true); $arr = [ 'id' => $v['id'], 'category_id' => $v['category_id'], 'category_child' => $v['category_child'], 'create_time' => $v['create_time'], 'update_time' => $v['update_time'], 'datas' => $a, 'data_field' => json_decode($v['data_field']), 'ai_question' => $v['ai_question'], 'ai_aianalyse' => $v['ai_aianalyse'], ]; if ($a) { array_push($datas, $arr); } } $item['datas'] = $datas; } return $item->toArray(); } }