$post['name'], 'content' => $post['content'], 'lang' => $post['lang'], 'sumx' => $sumx, 'status' => '1', ]); if (DB::affectedRows()) { $id = DB::insertID(); //s$count = count($post['downlink']); DB::where('id', $id)->update('download', ['parentId' => $id]); foreach ($post['downlink'] as $key) { DB::insert('downlink', [ 'country' => $key[0], 'link' => $key[1], 'downloadId' => $id, 'count' => '0', 'status' => '1', ]); } redirect('download'); } else { echo DB::error(); } } function copy($post) { $sumx = implode(',', $post['sumx']); $parentid = downloadParentId($post['id']); DB::insert('download', [ 'name' => $post['name'], 'content' => $post['content'], 'lang' => $post['lang'], 'sumx' => $sumx, 'status' => 1, ]); if (DB::affectedRows()) { $id = DB::insertID(); $count = count($post['downlink']); foreach($post['downlink'] as $key){ DB::insert('downlink',[ 'country' => $key[0], 'link' => $key[1], 'downloadId' => $id, 'count' =>'0', 'status' => 1, ]); } redirect('download'); }else{ echo DB::error(); } } function update($post) { $sumx = implode(',', $post['sumx']); DB::where('id', $post['id'])->update('download', [ 'name' => $post['name'], 'content' => $post['content'], 'lang' => $post['lang'], 'sumx' => $sumx, ]); DB::where('downloadId', $post['id'])->delete('downlink'); foreach ($post['downlink'] as $key) { if ($key[3] == "") { $status = '1'; } else { $status = $key[3]; } DB::insert('downlink', [ 'country' => $key[0], 'link' => $key[1], 'downloadId' => $post['id'], 'count' => $key[2], 'status' => $status ]); } redirect('download'); } }