Skip to content

Commit

Permalink
Fixed issue PHPcomRapadura#8
Browse files Browse the repository at this point in the history
Ao realizar uma busca por eventos sem data, um erro está sendo gerado pelo fato de nenhuma data ter sido passada. O ideal nesse caso é que retorne todos os eventos.
  • Loading branch information
marcreis committed May 13, 2018
1 parent 645c225 commit d7118d7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/Http/Controllers/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand All @@ -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 {

Expand Down

0 comments on commit d7118d7

Please sign in to comment.