예제 #1
0
    public function getListComments(Request $request, $idUser)
    {
        try {
            $PuCOmments = new PuComments();
            $table = $PuCOmments->CommentsForUser($idUser, null);
            $datatable = Datatables::of($table)->editColumn('picture', '<img src="{{$picture}}" heigth=64" width="64" />')->addColumn('action', function ($table) {
                return '<a href="/admpanel/' . self::NAMEC_PUBLICATION . '/form-comment/' . $table->id . '/' . self::NAMEC . '|comments|' . $table->user_id . '" class="btn-actions icon icon-pen"></a>' . '
				<a href="javascript:;" data-url="/admpanel/' . self::NAMEC_PUBLICATION . '/delete-comments/' . $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;
        }
    }
예제 #2
0
파일: PuComments.php 프로젝트: josmel/buen
 public function CommentsForUser($idUser = null, $idPost = null)
 {
     $table = PuComments::join('pu_ads as ads', 'pu_comments.pu_ad_id', '=', 'ads.id')->join('users as u', 'pu_comments.user_id', '=', 'u.id')->leftJoin('pr_providers as p', 'pu_comments.pr_provider_id', '=', 'p.id')->leftJoin('pr_types as prt', 'p.pr_type_id', '=', 'prt.id')->select('pu_comments.*', DB::raw('CONCAT("' . asset('') . '", u.picture) AS picture_user'), DB::raw('CONCAT("' . asset('') . '", p.picture_face) AS picture_provider'), DB::raw('CONCAT("' . asset('') . '", pu_comments.picture) AS picture'), DB::raw("(if(pu_comments.flagactive='1','Activo',(if(pu_comments.flagactive='0','Inactivo','-')))) as flagactive"), DB::raw("(if(pu_comments.flagactive='1','lock',(if(pu_comments.flagactive='0','unlock','-')))) as estado"), DB::raw('CONCAT(u.name, " ", u.lastname) AS name_user'), 'p.name_provider', 'prt.name_type as name_type_provider', 'u.name as nameUser', 'p.ranking as score', 'prt.id as id_type_provider');
     if ($idUser) {
         $table = $table->where('pu_comments.user_id', '=', $idUser);
     }
     if ($idPost) {
         $table = $table->where('pu_comments.pu_ad_id', '=', $idPost);
     }
     //                            ->where('u.flagactive', '=', 1)
     //				->where('pu_comments.flagactive', '=', 1)
     $table = $table->orderBy('pu_comments.flagactive', 'desc')->orderBy('pu_comments.datecreate', 'desc');
     return $table;
 }
예제 #3
0
파일: PuAds.php 프로젝트: josmel/buen
 public function getAllAds($category = null, $description = null, $user_id = null, $page, $type = null)
 {
     try {
         $data = PuAds::leftJoin('pu_pictures', 'pu_ads.id', '=', 'pu_pictures.pu_ad_id')->join('pu_types as t', 'pu_ads.pu_type_id', '=', 't.id')->join('users as u', 'pu_ads.user_id', '=', 'u.id')->join('pu_categories as ca', 'pu_ads.pu_category_id', '=', 'ca.id')->leftJoin('pr_providers as p', 'pu_ads.pr_provider_id', '=', 'p.id')->leftJoin('pr_comments as pc', 'pu_ads.pr_provider_id', '=', 'pc.id')->leftJoin('pr_types as prt', 'p.pr_type_id', '=', 'prt.id')->select('pu_ads.*', DB::raw('CONCAT("' . asset('') . '", pu_pictures.url) AS picture_publication'), DB::raw('CONCAT("' . asset('') . '", u.picture) AS picture_user'), DB::raw('CONCAT("' . asset('') . '",' . ' p.picture_face) AS picture_provider'), DB::raw('CONCAT("' . asset('') . '", ca.picture) AS picture_category'), DB::raw('CONCAT(u.name, " ", u.lastname) AS name_user'), 'u.idfacebook', 'prt.name_type as name_type_provider', 'p.name_provider', 'p.pu_category_id', 'ca.name_category', 'p.ranking as ranking_provider', 't.name_type', 'prt.id as id_type_provider');
         if ($category != null) {
             $data = $data->whereIn('pu_ads.pu_category_id', $category);
         }
         if ($description != null) {
             $data = $data->where('pu_ads.description', 'like', '%' . $description . '%');
         }
         if ($user_id != null) {
             $data = $data->where('pu_ads.user_id', '=', $user_id);
         }
         if ($type != null) {
             $data = $data->where('t.name_type', '=', $type);
         }
         $data = $data->where('pu_ads.flagactive', '=', 1)->skip($this->perpage * ($page - 1))->orderBy('pu_ads.pu_type_id', 'desc')->orderBy('pu_ads.lastupdate', 'desc')->groupBy('pu_ads.id')->take($this->perpage)->get();
         $dataFinish = $data->toArray();
         if ($dataFinish) {
             foreach ($dataFinish as $value) {
                 $likes = PuLikes::wherePuAdId($value['id'])->select(DB::raw('count(id) as likes'))->get();
                 $comments = PuComments::wherePuAdId($value['id'])->select(DB::raw('count(id) as comments'))->get();
                 $valueFinal = ["id" => $value["id"], "idfacebook" => $value["idfacebook"], "pu_type_id" => $value["pu_type_id"], "pu_category_id" => $value["pu_category_id"], "pu_state_id" => $value["pu_state_id"], "user_id" => $value["user_id"], "description" => $value["description"], "date_publish" => $value["date_publish"], "date_expired" => $value["date_expired"], "flagactive" => $value["flagactive"], "datecreate" => $value["datecreate"], "lastupdate" => $value["lastupdate"], "picture_publication" => $value["picture_publication"], "picture_user" => $value["picture_user"], "picture_category" => $value["picture_category"], "name_user" => $value["name_user"], "name_category" => $value["name_category"], "name_type" => $value["name_type"], "likes" => $likes[0]->likes, "comments" => $comments[0]->comments];
                 if ($value['pr_provider_id']) {
                     $score = PrScore::wherePrProviderId($value['pr_provider_id'])->select(DB::raw('count(id) as score'))->get();
                     $providerCategory = Categories::whereId($value['pu_category_id'])->select('name_category', DB::raw('CONCAT("' . asset('') . '", picture) AS picture_category'))->first();
                     $EstadoTipo = $value['name_type_provider'] == PrProviders::Type_Inactivo ? "0" : "1";
                     $valueFinal['provider'] = [['pr_provider_id' => $value['pr_provider_id'], 'id_type_provider' => $value['id_type_provider'], 'name_provider' => $value['name_provider'], 'name_type_provider' => $value['name_type_provider'], 'approved' => $EstadoTipo, "total_users" => $score[0]->score, "score" => $value["ranking_provider"], 'picture_provider' => $value['picture_provider'], 'name_category' => $providerCategory->name_category, 'picture_category' => $providerCategory->picture_category]];
                 } else {
                     $valueFinal['provider'] = [];
                 }
                 $dataFinish1[] = $valueFinal;
             }
         } else {
             $dataFinish1 = [];
         }
         return $dataFinish1;
     } catch (Exception $exc) {
         echo $exc->getTraceAsString();
         exit;
     }
 }
예제 #4
0
 /**
  *
  * @return Response
  */
 public function store(RegisterCommentPublicationRequest $request)
 {
     try {
         $dataPublication = $request->all();
         $dataPublication['user_id'] = $this->_identity->id;
         if (isset($dataPublication['picture'])) {
             $file = base64_decode($dataPublication['picture']);
             $pathrelative = "/dinamic/pu_comment/" . date('YmdHis') . rand(1, 1000) . ".jpg";
             $path = App::publicPath() . $pathrelative;
             file_put_contents($path, $file);
             $dataPublication['picture'] = $pathrelative;
         }
         $objPublication = PuComments::create($dataPublication);
         $Notification = new RequestNotification();
         $Notification->setNotification($this->_identity->id, $dataPublication['pu_ad_id'], RequestNotification::COMMMENT);
         $this->_responseWS->setDataResponse(Response::HTTP_OK, ['id' => $objPublication->id], [], 'ok');
     } catch (\Exception $exc) {
         dd($exc->getMessage());
         $this->_responseWS->setDataResponse(Response::HTTP_INTERNAL_SERVER_ERROR, [], [], '');
     }
     $this->_responseWS->response();
 }
예제 #5
0
 public function getDeleteComments($id)
 {
     $result = array('state' => 0, 'msg' => '');
     try {
         if (!$id) {
             throw new \Exception("Id de Comment vacio");
         }
         $user = PuComments::whereId($id)->first();
         $flagactive = $user->flagactive == 0 ? 1 : 0;
         $user->update(['id' => $id, 'flagactive' => $flagactive]);
         $result['state'] = 1;
     } catch (\Exception $e) {
         $result['msg'] = $e->getMessage();
     }
     return response()->json($result);
 }
예제 #6
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(Request $request, $id)
 {
     try {
         //            $this->haveAdsForUser($id);
         $dataPuCommentsForAds = new PuComments();
         $dataAds = $dataPuCommentsForAds->getAllCommentForAds($id, $request->input('page'));
         $this->_responseWS->setDataResponse(Response::HTTP_OK, $dataAds, array(), 'ok');
     } catch (Exception $exc) {
         $this->_responseWS->setDataResponse(Response::HTTP_INTERNAL_SERVER_ERROR, array(), array(), '');
     }
     $this->_responseWS->response();
 }