public function getCategory() { $cat = Categorias::where('tipo', '=', 1)->where('deleted', '=', 0)->get(array('id', 'desc')); $ser = Categorias::where('tipo', '=', 2)->where('deleted', '=', 0)->get(array('id', 'desc')); return Response::json(array('type' => 'success', 'categorias' => $cat, 'servicios' => $ser)); }
public function getPublicationCasual() { $pub = Publicaciones::where('user_id', '=', Auth::id())->where('tipo', '=', 'Casual')->where('fechRepub', '>', date('Y-m-d', time()))->orderBy('fechRepub', 'desc')->first(); if (count($pub) > 0 && Auth::id() != 21) { Session::flash('error', 'Usted ha consumido el máximo de publicaciones casuales. Inténtelo nuevamente cuando su última publicación casual expire.'); return Redirect::to('usuario/publicar'); } $title = "Publicación CASUAL | pasillo24.com"; $url = 'usuario/publicacion/casual/enviar'; $departamentos = Department::get(); $categorias = Categorias::where('tipo', '=', 1)->where('deleted', '=', 0)->orderBy('nombre')->get(); $otros = new StdClass(); foreach ($categorias as $c) { if (strtolower($c->nombre) == 'otros') { $otros->id = $c->id; $otros->nombre = $c->nombre; } } if (!isset($otros->id)) { $otros->id = '1000'; $otros->nombre = 'Otros'; } $servicios = Categorias::where('tipo', '=', 2)->where('deleted', '=', 0)->orderBy('nombre')->get(); $otros2 = new StdClass(); foreach ($servicios as $c) { if (strtolower($c->nombre) == 'otros') { $otros2->id = $c->id; $otros2->nombre = $c->nombre; } } if (!isset($otros2->id)) { $otros2->id = '1000'; $otros2->nombre = 'Otros'; } $textos = Textos::where('id', '=', 3)->first(); return View::make('publications.publicacion')->with('tipo', 'casual')->with('url', $url)->with('title', $title)->with('departamento', $departamentos)->with('categorias', $categorias)->with('texto', $textos)->with('servicios', $servicios)->with('otros', $otros)->with('otros2', $otros2); }
public function getReactivate($id) { $title = "Reactivar publicación | Pasillo24"; $pub = Publicaciones::find($id); $pub->duracion = 0; if ($pub->tipo == 'Lider') { $cat = Categorias::where('tipo', '=', 1)->where('deleted', '=', 0)->orderBy('nombre')->get(); $otros = new StdClass(); foreach ($cat as $c) { if (strtolower($c->nombre) == 'otros') { $otros->id = $c->id; $otros->nombre = $c->nombre; } } if (!isset($otros->id)) { $otros->id = '1000'; $otros->nombre = 'Otros'; } $serv = Categorias::where('tipo', '=', 2)->where('deleted', '=', 0)->orderBy('nombre')->get(); $otros2 = new StdClass(); foreach ($serv as $c) { if (strtolower($c->nombre) == 'otros') { $otros2->id = $c->id; $otros2->nombre = $c->nombre; } } if (!isset($otros2->id)) { $otros2->id = '1000'; $otros2->nombre = 'Otros'; } $pub->monto = 0; $pub->save(); return View::make('publications.reactivate')->with('title', $title)->with('pub', $pub)->with('cat', $cat)->with('serv', $serv)->with('otros', $otros)->with('otros2', $otros2); } else { $precioLider = Precios::where('pub_type_id', '=', 1)->get(); $precioCat = Precios::where('pub_type_id', '=', 2)->get(); $pub->monto = 40; $pub->save(); return View::make('publications.reactivate')->with('title', $title)->with('pub', $pub)->with('precioLider', $precioLider)->with('precioCat', $precioCat); } }
public function allCat() { $usuario = User::where('username', '=', Input::get('username'))->first(); $categorias = Categorias::where('activa', '=', '1')->get(); return Response::json($categorias); }
public function buscar() { echo $buscar = htmlspecialchars(Input::get('buscar')); echo $categorias = Categorias::where('categorias', 'LIKE', '%' . $buscar . '%')->get(); }
public function getModifySubCategories($id) { $sc = SubCat::find($id); $cat = Categorias::where('deleted', '=', 0)->get(); $title = "Modificar Sub-categorias | pasillo24"; return View::make('admin.modifySubCat')->with('title', $title)->with("sc", $sc)->with('cat', $cat)->with('id', $id); }
public function agregarB() { $categorias = Categorias::where('activa', '=', '1')->lists('nombre', 'id'); return View::make('Restaurante.agregarB')->with('categorias', $categorias); }
public function editarc() { if (Input::has('Editar')) { $categoria = Categorias::find(Input::get('cat_id')); return View::make('Admin.categorias2', compact('categoria')); } if (Input::has('Eliminar')) { $categoria = Categorias::where('id', '=', Input::get('cat_id'))->get(); $categoria[0]->delete(); return Redirect::to('admin/categorias')->with('message', 'Categoría eliminada con éxito'); } }
public function getSearch() { $title = "Búsqueda | pasillo24.com"; $paginatorFilter = ""; if (Input::has('busq')) { $busq = Input::get('busq'); $auxLider = Publicaciones::leftJoin('categoria', 'categoria.id', '=', 'publicaciones.categoria')->where('publicaciones.status', '=', 'Aprobado')->where('publicaciones.deleted', '=', 0)->where(function ($query) { $query->where('publicaciones.ubicacion', '=', 'Categoria')->orWhere('publicaciones.ubicacion', '=', 'Ambos'); })->where(function ($query) { $query->where('publicaciones.fechFin', '>=', date('Y-m-d'))->orWhere('publicaciones.fechFinNormal', '>=', date('Y-m-d')); })->where(function ($query) use($busq) { $query->whereRaw("LOWER(`publicaciones`.`titulo`) LIKE '%" . strtolower($busq) . "%'")->orWhereRaw("LOWER(`publicaciones`.`pag_web`) LIKE '%" . strtolower($busq) . "%'")->orWhereRaw("LOWER(`categoria`.`desc`) LIKE '%" . strtolower($busq) . "%'"); }); $auxRes = Publicaciones::leftJoin('categoria', 'publicaciones.categoria', '=', 'categoria.id')->leftJoin('departamento', 'publicaciones.departamento', '=', 'departamento.id')->where(function ($query) use($busq) { $query->whereRaw("LOWER(`publicaciones`.`titulo`) LIKE '%" . strtolower($busq) . "%'")->orWhereRaw("LOWER(`departamento`.`nombre`) LIKE '%" . strtolower($busq) . "%'")->orWhereRaw("LOWER(`categoria`.`desc`) LIKE '%" . strtolower($busq) . "%'"); })->where(function ($query) { $query->where('publicaciones.fechFin', '>=', date('Y-m-d'))->orWhere('publicaciones.fechFinNormal', '>=', date('Y-m-d')); })->where('publicaciones.tipo', '!=', 'Lider')->where('publicaciones.status', '=', 'Aprobado')->where('publicaciones.deleted', '=', 0); /*Se agrega*/ if (Input::has('filter')) { $filter = Input::get('filter'); if ($filter != -1) { $filter = Department::find(Input::get('filter')); $auxRes = $auxRes->where('publicaciones.departamento', '=', $filter->id); $paginatorFilter .= '&filter=' . $filter->id; } else { $filter = ""; } } if (Input::has('min') || Input::has('max')) { $min = Input::get('min'); $max = Input::get('max'); $currency = Input::get('currency'); if (!is_null($min) && !is_null($max) && !empty($min) && !empty($max)) { $minmax = array($min, $max); $paginatorFilter .= '&min=' . $min . '&max=' . $max . '¤cy=' . $currency; $auxLider = $auxLider->where('moneda', '=', $currency)->where('precio', '>=', $min)->whereRaw('`publicaciones`.`precio` <= ' . $max); $auxRes = $auxRes->where('publicaciones.precio', '>=', $min)->whereRaw('`publicaciones`.`precio` <= ' . $max)->where('publicaciones.moneda', '=', $currency); } else { if (!is_null($max) && !empty($max)) { $minmax = array('', $max); $paginatorFilter .= '&max=' . $max . '¤cy=' . $currency; $auxLider = $auxLider->where('moneda', '=', $currency)->whereRaw('`publicaciones`.`precio` <= ' . $max); $auxRes = $auxRes->whereRaw('`publicaciones`.`precio` <= ' . $max)->where('publicaciones.moneda', '=', $currency); } elseif (!is_null($min) && !empty($min)) { $minmax = array($min, ''); $paginatorFilter .= '&min=' . $min . '¤cy=' . $currency; $auxLider = $auxLider->where('moneda', '=', $currency)->where('precio', '>=', $min); $auxRes = $auxRes->where('publicaciones.moneda', '=', $currency)->where('publicaciones.precio', '>=', $min); } } } if (Input::has('rel')) { $rel = Input::get('rel'); switch ($rel) { case 'rep': $auxLider = $auxLider->leftJoin('usuario', 'usuario.id', '=', 'publicaciones.user_id')->orderBy('usuario.reputation', 'DESC'); $auxRes = $auxRes->leftJoin('usuario', 'usuario.id', '=', 'publicaciones.user_id')->orderBy('usuario.reputation', 'DESC'); $paginatorFilter .= '&rel=rep'; break; case 'fin': $auxLider = $auxLider->orderBy('publicaciones.fechFin', 'ASC')->orderBy('publicaciones.fechFinNormal', 'ASC'); $auxRes = $auxRes->orderBy('publicaciones.fechFin', 'ASC')->orderBy('publicaciones.fechFinNormal', 'ASC'); $paginatorFilter .= '&rel=fin'; break; case 'ini': $auxLider = $auxLider->orderBy('publicaciones.fechIni', 'DESC')->orderBy('publicaciones.fechIniNormal', 'DESC'); $auxRes = $auxRes->orderBy('publicaciones.fechIni', 'DESC')->orderBy('publicaciones.fechIniNormal', 'DESC'); $paginatorFilter .= '&rel=ini'; break; default: break; } } if (Input::has('cond')) { $cond = Input::get('cond'); $paginatorFilter .= '&cond=' . $cond; $auxRes = $auxRes->where('publicaciones.condicion', '=', strtolower($cond)); } if (Input::has('buss')) { $buss = Input::get('buss'); $paginatorFilter .= '&buss=' . $buss; $auxLider = $auxLider->where('publicaciones.bussiness_type', '=', strtolower($buss)); $auxRes = $auxRes->where('publicaciones.bussiness_type', '=', strtolower($buss)); } $lider = $auxLider->get(array('publicaciones.id', 'publicaciones.img_1', 'publicaciones.titulo', 'publicaciones.precio', 'publicaciones.moneda')); $res = $auxRes->paginate(5, array('publicaciones.id', 'publicaciones.img_1', 'publicaciones.titulo', 'publicaciones.precio', 'publicaciones.moneda', 'publicaciones.descripcion', 'publicaciones.fechFin', 'publicaciones.fechFinNormal', 'departamento.id as dep_id', 'departamento.nombre as dep')); $categorias = Categorias::where('id', '=', $busq)->pluck('desc'); if (!is_null($categorias)) { $busq = $categorias; } else { $busq = $busq; } $departamentos = Department::get(); $view = View::make('publications.busq')->with('publicaciones', $res)->with('title', $title)->with('busq', $busq)->with('lider', $lider)->with('departamento', $departamentos)->with('paginatorFilter', $paginatorFilter); if (isset($filter)) { $view = $view->with('filter', $filter); } if (isset($currency)) { $view = $view->with('minmax', $minmax)->with('currency', $currency); } if (isset($cond)) { $view = $view->with('cond', $cond); } if (isset($buss)) { $view = $view->with('buss', $buss); } if (isset($rel)) { $view = $view->with('rel', $rel); } return $view; } elseif (Input::has('cat')) { $id = Input::geT('cat'); /*Query inicial*/ $auxLider = Publicaciones::where('status', '=', 'Aprobado')->where('deleted', '=', 0)->where(function ($query) { $query->where('ubicacion', '=', 'Categoria')->orWhere('ubicacion', '=', 'Ambos'); })->where(function ($query) { $query->where('fechFin', '>=', date('Y-m-d'))->orWhere('fechFinNormal', '>=', date('Y-m-d')); })->where('categoria', '=', $id); //->get(array('id','img_1','titulo','precio','moneda')); $auxRes = Publicaciones::leftJoin('departamento', 'publicaciones.departamento', '=', 'departamento.id')->where('publicaciones.status', '=', 'Aprobado')->where('publicaciones.categoria', '=', $id)->where('publicaciones.tipo', '!=', 'Lider')->where('publicaciones.deleted', '=', 0)->where(function ($query) { $query->where('publicaciones.ubicacion', '=', 'Categoria')->orWhere('publicaciones.ubicacion', '=', 'Ambos'); })->where(function ($query) { $query->where('publicaciones.fechFin', '>=', date('Y-m-d', time()))->orWhere('publicaciones.fechFinNormal', '>=', date('Y-m-d', time())); }); /*Se agrega*/ if (Input::has('filter')) { $filter = Input::get('filter'); if ($filter != -1) { $filter = Department::find(Input::get('filter')); $auxRes = $auxRes->where('publicaciones.departamento', '=', $filter->id); $paginatorFilter .= '&filter=' . $filter->id; } else { $filter = ""; } } if (Input::has('min') || Input::has('max')) { $min = Input::get('min'); $max = Input::get('max'); $currency = Input::get('currency'); if (!is_null($min) && !is_null($max) && !empty($min) && !empty($max)) { $minmax = array($min, $max); $paginatorFilter .= '&min=' . $min . '&max=' . $max . '¤cy=' . $currency; $auxLider = $auxLider->whereRaw('`publicaciones`.`precio` >= ' . $min)->whereRaw('`publicaciones`.`precio` <= ' . $max)->where('moneda', '=', $currency); $auxRes = $auxRes->whereRaw('`publicaciones`.`precio` >= ' . $min)->whereRaw('`publicaciones`.`precio` <= ' . $max)->where('publicaciones.moneda', '=', $currency); } else { if (!is_null($max) && !empty($max)) { $minmax = array('', $max); $paginatorFilter .= '&max=' . $max . '¤cy=' . $currency; $auxLider = $auxLider->where('moneda', '=', $currency)->whereRaw('`publicaciones`.`precio` <= ' . $max); $auxRes = $auxRes->whereRaw('`publicaciones`.`precio` <= ' . $max)->where('publicaciones.moneda', '=', $currency); } elseif (!is_null($min) && !empty($min)) { $minmax = array($min, ''); $paginatorFilter .= '&min=' . $min . '¤cy=' . $currency; $auxLider = $auxLider->whereRaw('`publicaciones`.`precio` >= ' . $min)->where('moneda', '=', $currency); $auxRes = $auxRes->where('publicaciones.moneda', '=', $currency)->whereRaw('`publicaciones`.`precio` >= ' . $min); } } } if (Input::has('rel')) { $rel = Input::get('rel'); switch ($rel) { case 'rep': $auxLider = $auxLider->leftJoin('usuario', 'usuario.id', '=', 'publicaciones.user_id')->orderBy('usuario.reputation', 'DESC'); $auxRes = $auxRes->leftJoin('usuario', 'usuario.id', '=', 'publicaciones.user_id')->orderBy('usuario.reputation', 'DESC'); $paginatorFilter .= '&rel=rep'; break; case 'fin': $auxLider = $auxLider->orderBy('publicaciones.fechFin', 'ASC')->orderBy('publicaciones.fechFinNormal', 'ASC'); $auxRes = $auxRes->orderBy('publicaciones.fechFin', 'ASC')->orderBy('publicaciones.fechFinNormal', 'ASC'); $paginatorFilter .= '&rel=fin'; break; case 'ini': $auxLider = $auxLider->orderBy('publicaciones.fechIni', 'DESC')->orderBy('publicaciones.fechIniNormal', 'DESC'); $auxRes = $auxRes->orderBy('publicaciones.fechIni', 'DESC')->orderBy('publicaciones.fechIniNormal', 'DESC'); $paginatorFilter .= '&rel=ini'; break; default: break; } } if (Input::has('cond')) { $cond = Input::get('cond'); $paginatorFilter .= '&cond=' . $cond; $auxRes = $auxRes->where('publicaciones.condicion', '=', strtolower($cond)); } if (Input::has('buss')) { $buss = Input::get('buss'); $paginatorFilter .= '&buss=' . $buss; $auxLider = $auxLider->where('publicaciones.bussiness_type', '=', strtolower($buss)); $auxRes = $auxRes->where('publicaciones.bussiness_type', '=', strtolower($buss)); } $lider = $auxLider->get(array('publicaciones.id', 'publicaciones.img_1', 'publicaciones.titulo', 'publicaciones.precio', 'publicaciones.moneda')); $res = $auxRes->paginate(5, array('publicaciones.id', 'publicaciones.img_1', 'publicaciones.titulo', 'publicaciones.precio', 'publicaciones.moneda', 'publicaciones.descripcion', 'publicaciones.fechFin', 'publicaciones.fechFinNormal', 'departamento.id as dep_id', 'departamento.nombre as dep')); $categorias = Categorias::where('id', '=', $id)->pluck('id'); if (!is_null($categorias)) { $busq = $categorias; } else { $busq = $id; } $departamentos = Department::get(); $view = View::make('publications.categories')->with('publicaciones', $res)->with('title', $title)->with('busq', $busq)->with('lider', $lider)->with('departamento', $departamentos)->with('paginatorFilter', $paginatorFilter); if (isset($filter)) { $view = $view->with('filter', $filter); } if (isset($currency)) { $view = $view->with('minmax', $minmax)->with('currency', $currency); } if (isset($cond)) { $view = $view->with('cond', $cond); } if (isset($buss)) { $view = $view->with('buss', $buss); } if (isset($rel)) { $view = $view->with('rel', $rel); } return $view; } }