public function resulttheoloaicongvan(IncongvandiFormRequest $request)
 {
     $menus = Menu::all();
     $loaicongvans = Danhmucloaicongvan::all();
     $ngaynhanbatdau = $request->input('ngaynhanbatdau');
     $ngaynhanketthuc = $request->input('ngaynhanketthuc');
     $loaicongvan = $request->input('loaicongvan');
     //$capphathanhresult = 'Tất cả';
     if ($loaicongvan == 0) {
         $queryloaicongvan = 'danhmucloaicongvan_id > 0';
         $loaicongvanresult = 'Tất cả';
     } else {
         $queryloaicongvan = 'danhmucloaicongvan_id = ' . $loaicongvan;
         $loaicongvanresult = Danhmucloaicongvan::where('id', $loaicongvan)->select('name')->first();
     }
     if ($ngaynhanbatdau != '' && $ngaynhanketthuc != '') {
         $ngaynhanbatdau = date('Y-m-d', strtotime(str_replace('/', '-', $ngaynhanbatdau)));
         //date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngayphathanh-start'))) ) ;
         $ngaynhanketthuc = date('Y-m-d', strtotime(str_replace('/', '-', $ngaynhanketthuc)));
         if ($ngaynhanbatdau > $ngaynhanketthuc) {
             return \Redirect::route('baocaocongvandi.theoloaicongvan')->withErrors('Ngày nhận bắt đầu phải nhỏ hơn ngày nhận kết thúc!')->withInput();
         } else {
             $congvandis = Congvandi::where('ngayphathanh', '>=', $ngaynhanbatdau)->where('ngayphathanh', '<=', $ngaynhanketthuc)->whereRaw($queryloaicongvan)->get();
         }
     }
     //$tungay = '01/02/2015';
     //$denngay = '01/06/2015';
     $tungays = date('d/m/Y', strtotime($ngaynhanbatdau));
     //date('Y-m-d', strtotime(str_replace('/', '-', Input::get('ngayphathanh-start'))) ) ;
     $denngays = date('d/m/Y', strtotime($ngaynhanketthuc));
     //echo '<pre>';
     //print_r($congvandis);
     return view('baocaocongvandi.theoloaicongvan')->with(['menus' => $this->menus, 'tungay' => $tungays, 'denngay' => $denngays, 'congvandis' => $congvandis, 'loaicongvans' => $loaicongvans, 'loaicongvanresult' => $loaicongvanresult])->withInput($request);
 }
 public function search(DanhmucloaicongvanSearchIndexRequest $query)
 {
     $menus = Menu::all();
     $querys = $query->input('query');
     $danhmucloaicongvans = Danhmucloaicongvan::where('name', 'LIKE', '%' . $querys . '%')->orderBy('name')->paginate(10);
     if ($danhmucloaicongvans == NULL) {
         $danhmucloaicongvans = 'Không Tìm Thấy';
     }
     return view('danhmucloaicongvan.index')->with(array('danhmucloaicongvans' => $danhmucloaicongvans, 'menus' => $this->menus));
 }