public function search(DanhmucmucdichSearchIndexRequest $query) { $menus = Menu::all(); $querys = $query->input('query'); $danhmucmucdichs = Danhmucmucdich::where('name', 'LIKE', '%' . $querys . '%')->orderBy('name')->paginate(10); if ($danhmucmucdichs == NULL) { $danhmucmucdichs = 'Không Tìm Thấy'; } return view('danhmucmucdich.index')->with(array('danhmucmucdichs' => $danhmucmucdichs, 'menus' => $this->menus)); }
public function resulttheomucdich(IncongvandiFormRequest $request) { $menus = Menu::all(); $mucdichs = Danhmucmucdich::all(); $ngaynhanbatdau = $request->input('ngaynhanbatdau'); $ngaynhanketthuc = $request->input('ngaynhanketthuc'); $mucdich = $request->input('mucdich'); //$capphathanhresult = 'Tất cả'; if ($mucdich == 0) { $querymucdich = 'danhmucmucdich_id > 0'; $mucdichresult = 'Tất cả'; } else { $querymucdich = 'danhmucmucdich_id = ' . $mucdich; $mucdichresult = Danhmucmucdich::where('id', $mucdich)->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.theomucdich')->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($querymucdich)->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.theomucdich')->with(['menus' => $this->menus, 'tungay' => $tungays, 'denngay' => $denngays, 'congvandis' => $congvandis, 'mucdichs' => $mucdichs, 'mucdichresult' => $mucdichresult])->withInput($request); }