From d7118d7ab8cc10c0535c39c2cc569f3f2ebc4789 Mon Sep 17 00:00:00 2001 From: Marcelo Reis Date: Sun, 13 May 2018 02:20:05 -0300 Subject: [PATCH] =?UTF-8?q?Fixed=20issue=20#8=20Ao=20realizar=20uma=20busc?= =?UTF-8?q?a=20por=20eventos=20sem=20data,=20um=20erro=20est=C3=A1=20sendo?= =?UTF-8?q?=20gerado=20pelo=20fato=20de=20nenhuma=20data=20ter=20sido=20pa?= =?UTF-8?q?ssada.=20O=20ideal=20nesse=20caso=20=C3=A9=20que=20retorne=20to?= =?UTF-8?q?dos=20os=20eventos.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/EventController.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/EventController.php b/app/Http/Controllers/EventController.php index b8af44d..47daec3 100755 --- a/app/Http/Controllers/EventController.php +++ b/app/Http/Controllers/EventController.php @@ -20,12 +20,14 @@ public function index(Request $request) if (isset($data['dtinicial']) && isset($data['dtfinal'])) { $dataInicialNotEmpty = !empty($data['dtinicial']); + $dtinicial = ($dataInicialNotEmpty) ? \Carbon\Carbon::createFromFormat('d/m/Y', $data['dtinicial']) : \Carbon\Carbon::now(); $events = Event::where('datainicial', '>=', $dtinicial->toDateString()); + if(!empty($data['dtfinal'])){ $dtfinal = \Carbon\Carbon::createFromFormat('d/m/Y', $data['dtfinal']); @@ -35,9 +37,10 @@ public function index(Request $request) $events->orderBy('datainicial', 'ASC'); - $events = $events->paginate(2); + $events = $events->paginate(10); - return view('event.list', compact('events')) ; + return view('event.list', compact('events')) + ->with('i', ($request->input('page', 1) - 1) * 10) ; } else {