/** * * @return Response */ public function index(Request $request) { try { $dataAdsForUser = new PuAds(); $dataAds = $dataAdsForUser->getAllAdsForUser($this->_identity->id, $request->input('page')); $this->_responseWS->setDataResponse(Response::HTTP_OK, $dataAds->toArray(), array(), 'ok'); } catch (Exception $exc) { $this->_responseWS->setDataResponse(Response::HTTP_INTERNAL_SERVER_ERROR, array(), array(), ''); } $this->_responseWS->response(); }
public function getList(Request $request) { try { $PuPosts = new PuAds(); $table = $PuPosts->PostForDataTable(null, 'ok'); $datatable = Datatables::of($table)->editColumn('picture_publication', '<img src="{{$picture_publication}}" heigth=64" width="64" />')->addColumn('action', function ($table) { return '<a href="/admpanel/' . self::NAMEC_PUBLICATION . '/form/' . $table->id . '/' . self::NAMEC . '" class="btn-actions icon icon-pen"></a> <a href="javascript:;" data-url="/admpanel/' . self::NAMEC_PUBLICATION . '/delete/' . $table->id . '" class="btn-actions icon icon-' . $table->estado . ' js-change-confirm" title="' . $table->estado . '" data-status="' . $table->estado . '" data-id="' . $table->id . '" ></a>'; }); return $datatable->make(true); } catch (Exception $exc) { echo $exc->getTraceAsString(); exit; } }
public function index() { // $datos = DB::select("call post_popular(7,2)"); $modelSubsidiary = new PuAds(); $listPremiumAds_ = $modelSubsidiary->getAllAds(null, null, null, 1, PuTypes::TYPE_PREMIUM); $listPremiumAds_[0]['detalle'] = asset('') . 'admpanel/publication/form/' . $listPremiumAds_[0]['id']; $listPublishAds_ = $modelSubsidiary->getPublishAds_count(); $listSessions_ = $modelSubsidiary->getSessions_count(); $visits = new \stdClass(); $visits->viewers['Día'] = (int) $listSessions_->day_; $visits->viewers['Semana'] = (int) $listSessions_->week_; $visits->viewers['Mes'] = (int) $listSessions_->month_; $visits->posts['Día'] = (int) $listPublishAds_->day_; $visits->posts['Semana'] = (int) $listPublishAds_->week_; $visits->posts['Mes'] = (int) $listPublishAds_->month_; $listPremiumAds_ = json_encode($listPremiumAds_); $visits = json_encode($visits); return $this->renderView('admin.home.index', compact('listPremiumAds_', 'visits')); }
public function getAdsType($idPost, $value = null) { $dataAds = PuAds::join('pu_types as t', 'pu_ads.pu_type_id', '=', 't.id')->leftJoin('pu_comments as comment', 'pu_ads.id', '=', 'comment.pu_ad_id')->leftJoin('pu_likes as likes', 'pu_ads.id', '=', 'likes.pu_ad_id')->select('pu_ads.*', 't.*', DB::raw('count(comment.id) as comentario'), DB::raw('count(likes.id) as likes'))->where('pu_ads.id', '=', $idPost)->where('pu_ads.flagactive', '=', 1); if ($value) { switch ($value) { case 1: $dataAds = $dataAds->where('likes.flagactive', '=', 1); break; case 2: $dataAds = $dataAds->where('comment.flagactive', '=', 1); break; } } $dataAds = $dataAds->first(); return $dataAds; }
public function dataPremium($idPost) { $modelAds = new PuAds(); $modelTypeAds = new PuTypes(); $modelConfig = \App\Models\Configuration::whereFlagactive(1)->first(); $dataComentario = $modelAds->getAdsType($idPost, 2); $dataLike = $modelAds->getAdsType($idPost, 1); if ($dataComentario->comentario >= $modelConfig->limit_datear || $dataLike->likes >= $modelConfig->limit_buen_dato) { $type = $modelTypeAds->getIdPuType(PuTypes::TYPE_POPULAR); } else { $type = $modelTypeAds->getIdPuType(PuTypes::TYPE_COMUN); } return $type; }
/** * método que permite validar post de Usuario * * @param int $id * @return Response */ public function haveAdsForUser($id) { $dataAds = PuAds::whereId($id)->whereUserId($this->_identity->id)->whereFlagactive(1)->first(); if (isset($dataAds->id)) { return true; } else { $this->_responseWS->setDataResponse(Response::HTTP_NON_AUTHORITATIVE_INFORMATION, array(), array(), 'id de publicacion no permitida'); $this->_responseWS->response(); } }