public function download_segment(Request $request, $id) { $user_name = Auth::user(); $tmp_domen = Segment::where('id', '=', $id)->first(); $tmp_user = Users_site::where('id', '=', $tmp_domen['domen_id'])->first(); if ($tmp_user['user_id'] == $user_name['id']) { $subscribes_all = Subscribers::where('segment_id', '=', $id)->get(); $list = array(); foreach ($subscribes_all as $value) { array_push($list, array($value->email, $value->name, $value->surname, $value->sex, $value->age, $value->city, Subscriber_status::where('id', '=', $value['status_id'])->first()['status_name'])); } // $content = iconv('UTF-8', 'WINDOWS-1251', $content); $content = implode("\r\n", array_map(function ($x) { return '"' . implode('";"', $x) . '"'; }, $list)); return (new Response($content, 200))->header('Content-Description', 'File Transfer')->header('Content-Type', 'application/octet-stream')->header('Accept-Ranges', 'bytes')->header('Content-Transfer-Encoding', 'binary')->header('Expires', '0')->header('Cache-Control', 'must-revalidate')->header('Pragma', 'public')->header('Content-Length', strlen($content))->header('Content-disposition', 'attachment;filename=segment_' . $tmp_domen['id'] . '_' . date('Y-m-d') . '.csv'); } else { return redirect()->back(); } }
echo '<td>' . $subscribers_find->name . ' ' . $subscribers_find->surname . '</td>'; echo '<td>' . $subscribers_find->email . '</td>'; echo '<td>' . Subscriber_status::where('id', '=', $subscribers_find->status_id)->first()->status_name . '</td>'; echo '<td><a href="/dashboard/get_subscriber/' . $subscribers_find->id . '/' . $current_segment . '" class="subscribers__update">Редактировать</a></td>'; echo '</tr>'; } else { if (isset($subscribers_change_status) && $subscribers_change_status != null) { $subscribes = Subscribers::where('segment_id', '=', $current_segment)->where('status_id', '=', $subscribers_change_status)->paginate($pagination_number); } else { $subscribes = Subscribers::where('segment_id', '=', $current_segment)->paginate($pagination_number); } foreach ($subscribes as $value) { echo '<tr>'; echo '<td>' . $value->name . ' ' . $value->surname . '</td>'; echo '<td>' . $value->email . '</td>'; echo '<td>' . Subscriber_status::where('id', '=', $value->status_id)->first()->status_name . '</td>'; echo '<td><a href="/dashboard/get_subscriber/' . $value->id . '/' . $current_segment . '" class="subscribers__update">Редактировать</a></td>'; echo '</tr>'; } } } ?> </tbody> </table> <div class="row"> <div class="col-md-4 pull-right"> <select class="form-control paginate_filter_input" onchange="document.location=this.options[this.selectedIndex].value"> <option <?php if ($pagination_number == 10) { echo 'selected'; }