sourceTable) ->where(['status'=>'1','deleted'=>'0' ]) ->where('uniacid','>','0') ->get(); if($roles){ foreach($roles as $role){ $exists = \Illuminate\Support\Facades\DB::table($this->table) ->where(['uniacid'=>$role['uniacid'],'name'=>$role['rolename']]) ->exists(); if(!$exists){ \Illuminate\Support\Facades\DB::table($this->table)->insert([ 'name'=>$role['rolename'], 'uniacid'=>$role['uniacid'], 'created_at'=>time(), 'updated_at'=>time() ]); echo "迁移 uniacid:{$role['uniacid']} rolename:{$role['rolename']} 完成\n"; } //@todo insert yz_permission } } } }