public function downloadExcel(Request $request) { $dat_n = $request->input('dat_n'); $dat_k = $request->input('dat_k'); $type = $request->input('type'); $data = Pokaz::where('created_at', '>=', date("Y-m-d", strtotime($dat_n)))->where('created_at', '<=', date("Y-m-d", strtotime($dat_k)))->get()->toArray(); return Excel::create('itsolutionstuff_example', function ($excel) use($data) { $excel->sheet('mySheet', function ($sheet) use($data) { $sheet->fromArray($data); }); })->download($type); }
public function getPokaz() { if (Session::has('nls')) { $nls = Session::get('nls'); $user_info = Geng::with('npu')->where('nls', '=', $nls); $poks = Pokaz::where('nls', '=', $nls)->limit(6)->get(); $pokk = DB::select('SELECT nls,status,kontr_pk,d_pok,n_pok,data_k FROM ((SELECT nls,status,kontr_pk,d_pok,n_pok,created_at as data_k FROM site_pokaz WHERE nls=? and kontr_pk NOT IN (SELECT kontr_pk FROM pokaz_k WHERE nls=?)) UNION (SELECT nls,status,kontr_pk,d_pok,n_pok,data_k FROM pokaz_k a where nls=? ORDER BY data_k DESC LIMIT 7)) as t2 ORDER BY t2.data_k', [$nls, $nls, $nls]); if ($user_info->count()) { $user_info = $user_info->first(); $tarif = Marsh::find($user_info->npu->tip); Session::put('tar', $tarif->tar); return View::make('pokaz.input_pok', compact('user_info', 'poks', 'tarif', 'pokk')); } else { return Redirect('/input/')->withInput()->withAlert(Lang::get('book.nls')); } } else { return Redirect('/input/'); } }