public function resulttheochuyende(IncongvandiFormRequest $request) { $menus = Menu::all(); $chuyendes = Danhmucchuyende::all(); $ngaynhanbatdau = $request->input('ngaynhanbatdau'); $ngaynhanketthuc = $request->input('ngaynhanketthuc'); $chuyende = $request->input('chuyende'); //$capphathanhresult = 'Tất cả'; if ($chuyende == 0) { $querychuyende = 'danhmucchuyende_id > 0'; $chuyenderesult = 'Tất cả'; } else { $querychuyende = 'danhmucchuyende_id = ' . $chuyende; $chuyenderesult = Danhmucchuyende::where('id', $chuyende)->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.theochuyende')->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($querychuyende)->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.theochuyende')->with(['menus' => $this->menus, 'tungay' => $tungays, 'denngay' => $denngays, 'congvandis' => $congvandis, 'chuyendes' => $chuyendes, 'chuyenderesult' => $chuyenderesult])->withInput($request); }