public function getPublicationDepartment($id) { $title = "Búsqueda por departamento | pasillo24.com"; if ($id != 'todos') { $lider = Publicaciones::where('publicaciones.departamento', '=', $id)->where('tipo', '=', 'Lider')->where(function ($query) { $query->where('fechFin', '>=', date('Y-m-d', time()))->orWhere('fechFinNormal', '>=', date('Y-m-d', time())); })->get(array('id', 'img_1', 'titulo', 'precio')); $publicaciones = Publicaciones::where('publicaciones.departamento', '=', $id)->where(function ($query) { $query->where('fechFin', '>=', date('Y-m-d', time()))->orWhere('fechFinNormal', '>=', date('Y-m-d', time())); })->paginate(10, array('id', 'img_1', 'titulo', 'precio')); } else { $lider = Publicaciones::where('tipo', '=', 'Lider')->where(function ($query) { $query->where('fechFin', '>=', date('Y-m-d', time()))->orWhere('fechFinNormal', '>=', date('Y-m-d', time())); })->get(array('id', 'img_1', 'titulo', 'precio')); $publicaciones = Publicaciones::where(function ($query) { $query->where('fechFin', '>=', date('Y-m-d', time()))->orWhere('fechFinNormal', '>=', date('Y-m-d', time())); })->paginate(5, array('id', 'img_1', 'titulo', 'precio')); } return View::make('publications.categories')->with('title', $title)->with('publicaciones', $publicaciones)->with('tipoBusq', 'dep')->with('lider', $lider)->with('busq', 'departamentos'); }
public function getMyPublicationsType($type) { $id = Input::get('id'); if (strtolower($type) == "lider") { $publications = Publicaciones::where('user_id', '=', $id)->leftJoin('categoria', 'categoria.id', '=', 'publicaciones.categoria')->leftJoin('departamento', 'departamento.id', '=', 'publicaciones.departamento')->where('publicaciones.tipo', '=', ucfirst(strtolower($type)))->where('publicaciones.deleted', '=', 0)->get(array('publicaciones.*', 'categoria.nombre as categoria', 'departamento.nombre as dep_desc')); } elseif (strtolower($type) == "habitual") { $publications = Publicaciones::join('categoria', 'categoria.id', '=', 'publicaciones.categoria')->leftJoin('departamento', 'departamento.id', '=', 'publicaciones.departamento')->where('user_id', '=', $id)->where('publicaciones.tipo', '=', 'Habitual')->where('publicaciones.deleted', '=', 0)->get(array('publicaciones.*', 'categoria.nombre as categoria', 'departamento.nombre as dep_desc')); } elseif (strtolower($type) == "casual") { $publications = Publicaciones::join('categoria', 'categoria.id', '=', 'publicaciones.categoria')->leftJoin('departamento', 'departamento.id', '=', 'publicaciones.departamento')->where('publicaciones.user_id', '=', $id)->where('publicaciones.tipo', '=', 'Casual')->where('publicaciones.deleted', '=', 0)->get(array('publicaciones.*', 'categoria.nombre as categoria')); $rePub = Publicaciones::where('publicaciones.user_id', '=', $id)->where('publicaciones.tipo', '=', 'Casual')->where('publicaciones.deleted', '=', 0)->orderBy('fechRepub', 'desc')->first(array('fechRepub')); } if (strtolower($type) == "casual") { return Response::json(array('publications' => $publications, 'type' => strtolower($type), 'rePub' => $rePub)); } return Response::json(array('publications' => $publications, 'type' => strtolower($type))); }
public function postUserElim() { if (Request::ajax()) { $id = Input::get('id'); $pub = Publicaciones::where('user_id', '=', $id)->get(); $comment = Comentarios::where('user_id', '=', $id)->get(); $resp = Respuestas::where('user_id', '=', $id)->get(); $user = User::find($id); if (count($pub) > 0) { foreach ($pub as $p) { $p->deleted = 1; $p->save(); } } if (count($comment) > 0) { foreach ($comment as $c) { $c->deleted = 1; $c->save(); } } if (count($resp) > 0) { foreach ($resp as $r) { $r->deleted = 1; $r->save(); } } $username = $user->username; $email = $user->email; $user->user_deleted = 1; $subject = "Correo de administrador"; $admin = Auth::user()['username']; $data = array('subject' => $subject, 'usuario' => $username, 'creadoPor' => $admin); $to_Email = '*****@*****.**'; Mail::send('emails.elimUser', $data, function ($message) use($admin, $to_Email, $subject, $username) { $message->to($to_Email)->from('*****@*****.**')->subject($subject); }); $to_Email = $email; $data = array('subject' => 'Usuario eliminado en pasillo24.com'); Mail::send('emails.elimUserForUser', $data, function ($message) use($to_Email, $subject) { $message->to($to_Email)->from('*****@*****.**')->subject($subject); }); $user->save(); return Response::json(array('type' => 'success', 'msg' => 'Usuario eliminado satisfactoriamente.')); } }
public function getMyPublications() { $title = "Mis publicaciones"; $publications = Publicaciones::where('user_id', '=', Auth::id())->where('deleted', '=', 0)->get(); return View::make('user.publications')->with('title', $title)->with('publications', $publications); }
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; } }