','']; $where[] = ['name','not null','']; $where[] = ['initials','=','']; $arr = Employee::where($where)->column('id,name,initials'); foreach ($arr as $k => $v) { $initials = strtoupper(substr(hanzi2pinyin($v['name']),0,1)); Employee::where('id',$v['id'])->update(['initials'=>$initials]); } } }