setName('defreshemp') ->setDescription('deal old Employee data'); } protected function execute(Input $input, Output $output) { $records = Employee::field('id,phone')->select(); $i = 0; foreach($records as $item){ if(strlen($item->phone) == 11){ $output->writeln($item->phone); $cypherhone = cypherphone($item->phone); $output->writeln($i); $output->writeln($cypherhone); $i++; Employee::where('id',$item->id)->update(['phone' => $cypherhone]); } } $output->writeln($i." 条记录处理完毕"); } }