toArray(); // $fields = ['classify', 'brand', 'model', 'status', 'purchase_location', 'procedure_location', 'fbo_destination']; // foreach ($list as $key => &$item) { // foreach ($item as $k => &$v) { // if (in_array($k, $fields)) { // $xunfei = new Xunfei(); // $rst_dst = $xunfei->fanyi($v, 'cn', 'ar'); // if ($rst_dst) { // $list[$key][$k] = $rst_dst["trans_result"]["dst"]; // } // } // } // unset($v); // $id = $item['id']; // unset($item['id']); // unset($item['created_at']); // unset($item['updated_at']); // Db::table('vehicles_ar')->where('id', $id)->update($item); // $output->write("{$id}: 翻译 - 已处理 \n"); // } // unset($item); $list = Location::all()->toArray(); $fields = ['name', 'address', 'area']; foreach ($list as $key => &$item) { foreach ($item as $k => &$v) { if (in_array($k, $fields)) { $xunfei = new Xunfei(); $rst_dst = $xunfei->fanyi($v, 'cn', 'ru'); if ($rst_dst) { $list[$key][$k] = $rst_dst["trans_result"]["dst"]; } } } unset($v); $id = $item['id']; unset($item['id']); unset($item['created_at']); unset($item['updated_at']); Db::table('locations_ru')->where('id', $id)->update($item); $output->write("{$id}: 翻译 - 已处理 \n"); } unset($item); return self::SUCCESS; } }