/** * Display a listing of pacotes * * @return Response */ public function getIndex() { //$pacotes = new Pacote; if (Input::has('continente')) { $string = Input::get('continente'); $string = urldecode($string); $pais = Input::has('pais') ? Input::get('pais') : false; $pacotes = Pacote::whereHas('pais', function ($q) use($string, $pais) { $q->whereHas('continente', function ($q) use($string) { $q->where('name_pt', 'LIKE', "%{$string}%"); })->where('pais_id', $pais); })->where('publicado', '=', 1); } else { $pacotes = Pacote::where('publicado', '=', 1); } // if(Input::has('tipo')) // { // $pacotes = $pacotes->Where('tipo', '=', Input::get('tipo')); // } if (!$pacotes) { return Redirect::back()->with('warning', array('Não foram encontrados resultados na busca.')); } $pacotes->with('pais.continente'); $count = $pacotes->count(); $pacotes = $pacotes->paginate(5); $pacotes = $this->removeHtmlDescricao($pacotes); $continentes = Continente::all(); foreach ($continentes as $cont) { $json[] = $cont->name_pt; } $json = json_encode($json); //debug($pacotes->toArray()); return View::make('pacote.index', compact('pacotes', 'count', 'json')); }
public function getIndex() { // if(Auth::check()) // { // debug(Auth::user()->toArray()); // } $destinos = Destino::all(); $populares = Pacote::where('publicado', 1)->orderBy('visitas', 'DESC')->take(10)->get(); $eventos = EventoEspecial::Where('destaque', 1)->take(3)->get(); if ($eventos->isEmpty()) { $eventos = EventoEspecial::take(3)->get(); } //$cotacao_dolar = Configuracao::where('param', 'cotacao_dolar')->first()->valor; //debug($populares); foreach ($destinos as $destino) { $json[] = $destino->nome_br; } $json = json_encode($json); //debug(Session::get('carrinho')); return View::make('common.home2', compact('filter_hotel', 'json', 'populares', 'cotacao_dolar', 'eventos')); }