Example #1
0
 public function postPokaz(Request $request)
 {
     if (Session::has('nls')) {
         $tar = Session::get('tar');
         $nls = Session::get('nls');
         if ($tar == 1) {
             $messages = array('required' => Lang::get('book.nls_required'), 'numeric' => Lang::get('book.nls_numeric'));
             $v = Validator::make($request->all(), Geng::$rules['t1'], $messages);
             if ($v->fails()) {
                 return redirect()->back()->withInput()->withErrors($v);
             } else {
                 $kontr_d = $request->input('t1');
                 Pokaz::create(array('kontr_pk' => $kontr_d, 'nls' => $nls));
                 return Redirect('/input/pokaz')->withAlert(Lang::get('book.pok_save'));
             }
         } else {
             $messages = array('required' => Lang::get('book.nls_required'), 'numeric' => Lang::get('book.nls_numeric'));
             $v = Validator::make($request->all(), Geng::$rules['t2'], $messages);
             if ($v->fails()) {
                 return Redirect('/input/pokaz')->withInput()->withErrors($v);
             } else {
                 $kontr_d = Input::get('t1');
                 $kontr_n = Input::get('t2');
                 Pokaz::create(array('kontr_pk' => $kontr_d + $kontr_n, 'd_pok' => $kontr_d, 'n_pok' => $kontr_n, 'nls' => $nls));
                 return Redirect('/input/pokaz')->withAlert(Lang::get('book.pok_save'));
             }
         }
     }
 }
 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);
 }