public function index($id)
 {
     Session::set('last_projectid', $id);
     $search['text'] = Input::get('search_text');
     $search['type'] = Input::get('search_type');
     if ($search['type'] == 'user') {
         $list = Comment::where('nickname', $search['text'])->where('project_id', $id)->orderBy('id', 'desc')->paginate(20);
     } else {
         if ($search['type'] == 'ip') {
             $list = Comment::where('ip', 'like', "%{$search['text']}%")->where('project_id', $id)->orderBy('id', 'desc')->paginate(20);
         } else {
             if ($search['type'] == 'page_id') {
                 $list = Comment::where('page_id', 'like', "%{$search['text']}%")->where('project_id', $id)->orderBy('id', 'desc')->paginate(20);
             } else {
                 if ($search['type'] == 'fid') {
                     $list = Comment::where('fid', 'like', "%{$search['text']}%")->where('project_id', $id)->orderBy('id', 'desc')->paginate(20);
                 } else {
                     if ($search['type'] == 'path') {
                         $list = Comment::where('path', 'like', "%{$search['text']}%")->where('project_id', $id)->orderBy('id', 'desc')->paginate(20);
                     } else {
                         if ($search['type'] == 'content') {
                             $list = Comment::where('content', 'like', "%{$search['text']}%")->where('project_id', $id)->orderBy('id', 'desc')->paginate(20);
                         } else {
                             $list = Comment::where('project_id', $id)->orderBy('id', 'desc')->paginate(20);
                         }
                     }
                 }
             }
         }
     }
     return View::make('admin.comment_list')->withlist($list)->withsearch($search)->withproject_id($id);
 }
Ejemplo n.º 2
0
 public function show($slug)
 {
     $article = Content::article()->active()->published()->where('slug', $slug)->firstOrFail();
     $comments = Comment::where('content_id', $article['id'])->active()->paginate(10);
     $pageTitle = $article['title'];
     return view('frontend.articles.show', compact('article', 'comments', 'pageTitle'));
 }
Ejemplo n.º 3
0
 public function search()
 {
     //dd(Request::only('keyword'));
     $keyword = Request::only('keyword')['keyword'];
     $results = Comment::where('content', 'like', '%' . $keyword . '%')->orWhere('author', 'like', '%' . $keyword . '%')->paginate(10);
     //dd($results);
     return redirect()->back()->withComments($results);
 }
Ejemplo n.º 4
0
 public function getDataSet($postData, $safetyTable, $facility_id, $occur_date, $properties)
 {
     $comment_type = $postData['CodeCommentType'];
     $comment = Comment::getTableName();
     //      	\DB::enableQueryLog();
     $dataSet = Comment::where("FACILITY_ID", "=", $facility_id)->where("COMMENT_TYPE", "=", $comment_type)->where("CREATED_DATE", "=", $occur_date)->select("{$comment}.ID as DT_RowId", "{$comment}.*")->get();
     //  		\Log::info(\DB::getQueryLog());
     return ['dataSet' => $dataSet];
 }
Ejemplo n.º 5
0
 public function update(Request $request, $id)
 {
     $this->validate($request, ['nickname' => 'required', 'content' => 'required']);
     if (Comment::where('id', $id)->update(Input::except(['_method', '_token']))) {
         return Redirect::to('admin/comments');
     } else {
         return Redirect::back()->withInput()->withErrors('更新失败!');
     }
 }
Ejemplo n.º 6
0
 public function show($id)
 {
     $rs = Blogs::find($id);
     if (!$rs) {
         echo json_encode(["blog_title" => "Not found", "blog_content" => "Not found"]);
         return;
     }
     $comment = Comment::where("comment_blogs_id", $id)->get();
     echo json_encode(["blog_title" => $rs->blog_title, "blog_content" => $rs->blog_content]);
     die;
 }
Ejemplo n.º 7
0
 public function listcomment(Request $request)
 {
     $type = $request->get('type');
     if ($type == 'all') {
         $comments = Models\Comment::all();
     } elseif ($type == 'act') {
         $comments = Models\Comment::where('item_type', '=', 'App\\Models\\Activity')->get();
     } elseif ($type == 'assoc') {
         $comments = Models\Comment::where('item_type', '=', 'App\\Models\\Associate')->get();
     }
     //print_r($comments[0]->item->title);die;
     return view('admin.comment.index', compact('comments'));
 }
Ejemplo n.º 8
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function product($id)
 {
     $product = Product::find($id);
     $avg_rating = Comment::where('product_id', '=', $product->id)->avg('rating');
     $rating_cont = Comment::where('product_id', '=', $product->id)->count();
     $five_star = Comment::where('product_id', '=', $product->id)->where('rating', '=', '5')->count() * 100 / $rating_cont;
     $four_star = Comment::where('product_id', '=', $product->id)->where('rating', '=', '4')->count() * 100 / $rating_cont;
     $three_star = Comment::where('product_id', '=', $product->id)->where('rating', '=', '3')->count() * 100 / $rating_cont;
     $two_star = Comment::where('product_id', '=', $product->id)->where('rating', '=', '2')->count() * 100 / $rating_cont;
     $one_star = Comment::where('product_id', '=', $product->id)->where('rating', '=', '1')->count() * 100 / $rating_cont;
     if (empty($product)) {
         Flash::error('Product not found');
         return redirect(route('admin.products.index'));
     }
     return view('site.products.show')->with(['product' => $product, 'avg_rating' => $avg_rating, 'rating_count' => $rating_cont, 'five_star' => $five_star, 'four_star' => $four_star, 'three_star' => $three_star, 'two_star' => $two_star, 'one_star' => $one_star]);
 }
Ejemplo n.º 9
0
 /**
  * Display a listing of the Comment.
  * GET|HEAD /comments
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $offset = $request->page ? $request->page : 1;
     $limit = $request->limit ? $request->limit : 12;
     $post_id = $request->post_id;
     $offset = ($offset - 1) * $limit;
     if ($post_id) {
         $posts = Comment::where('postId', $post_id)->orderBy('id', 'desc')->offset($offset)->limit($limit)->get();
         foreach ($posts as $key => $value) {
             $posts[$key]['human_created_at'] = $value->created_at->diffForHumans();
             $posts[$key]['human_updated_at'] = $value->updated_at->diffForHumans();
         }
     } else {
         $posts = Comment::orderBy('id', 'desc')->offset($offset)->limit($limit)->get();
     }
     return response()->json($posts);
 }
Ejemplo n.º 10
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $product = Product::findOrFail($id);
     $rating_cont = Comment::where('product_id', '=', $product->id)->count();
     $checked_rating_count = $rating_cont > 0 ? $rating_cont : 1;
     $five_star = Comment::where('product_id', '=', $product->id)->where('rating', '=', '5')->count() * 100 / $checked_rating_count;
     $four_star = Comment::where('product_id', '=', $product->id)->where('rating', '=', '4')->count() * 100 / $checked_rating_count;
     $three_star = Comment::where('product_id', '=', $product->id)->where('rating', '=', '3')->count() * 100 / $checked_rating_count;
     $two_star = Comment::where('product_id', '=', $product->id)->where('rating', '=', '2')->count() * 100 / $checked_rating_count;
     $one_star = Comment::where('product_id', '=', $product->id)->where('rating', '=', '1')->count() * 100 / $checked_rating_count;
     $owner = $product->owner();
     $mods = $product->mods();
     if (empty($product)) {
         Flash::error('Product not found');
         return redirect(route('admin.products.index'));
     }
     return view('site.products.show')->with(['product' => $product, 'rating_count' => $rating_cont, 'five_star' => $five_star, 'four_star' => $four_star, 'three_star' => $three_star, 'two_star' => $two_star, 'one_star' => $one_star, 'owner' => $owner, 'mods' => $mods]);
 }
Ejemplo n.º 11
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     $author = User::whereHas('role', function ($q) {
         $q->where('slug', 'admin');
     })->first();
     $categories = Category::where('is_active', 1)->get();
     $postsRecents = Post::where('is_active', 1)->where('seen', 1)->orderBy('created_at', 'desc')->take(3)->get();
     $postsPopular = Post::where('is_active', 1)->where('seen', 1)->orderBy('nview', 'desc')->take(3)->get();
     $commentsRecents = Comment::where('seen', 1)->orderBy('created_at', 'desc')->take(3)->get();
     $tags = Tag::all();
     $INFO_SITE = Admin::first();
     view()->share('author', $author);
     view()->share('categories', $categories);
     view()->share('tags', $tags);
     view()->share('postsRecents', $postsRecents);
     view()->share('postsPopular', $postsPopular);
     view()->share('commentsRecents', $commentsRecents);
     view()->share('INFO_SITE', $INFO_SITE);
 }
Ejemplo n.º 12
0
 public function show($id)
 {
     Article::where('id', $id)->increment('views');
     //阅读量加1
     $article = Article::with(['comments' => function ($query) {
         $query->take(10);
     }])->find($id);
     //        dd($article);
     $views = Article::where('author_id', $article->author_id)->where('author_type', $article->author_type)->sum('views');
     $comments_count = Comment::where('article_id', $id)->count();
     $hots = Article::orderBy('views', 'desc')->take(10)->get();
     $is_like = false;
     $is_collection = false;
     $is_follow = false;
     if ($this->login_user) {
         $is_like = Like::where('user_id', $this->login_user->id)->where('like_type', 'article')->where('like_id', $id)->first();
         $is_collection = Collection::where('user_id', $this->login_user->id)->where('collection_type', 'article')->where('collection_id', $id)->first();
         $is_follow = DB::table('user_follow')->where('user_id', $this->login_user->id)->where('follow_id', $article->author_id)->first();
     }
     return view('front.article.index', compact('article', 'views', 'comments_count', 'hots', 'is_like', 'is_collection', 'is_follow'));
 }
Ejemplo n.º 13
0
 public function postComments($docId, $commentId)
 {
     $comment = Input::get('comment');
     $parent = Comment::where('doc_id', '=', $docId)->where('id', '=', $commentId)->first();
     $parent->load('user');
     $parent->type = 'comment';
     //Returns the new saved Comment with the User relationship loaded
     $result = $parent->addOrUpdateComment($comment);
     Event::fire(MadisonEvent::DOC_SUBCOMMENT, array('comment' => $result, 'parent' => $parent));
     return Response::json($result);
 }
Ejemplo n.º 14
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $contentId = $request->get('contentId') ?: null;
     $comments = Comment::where($contentId ? ['content_id' => $contentId] : [])->latest()->paginate();
     return view('backend.comments.index', compact('comments'));
 }
Ejemplo n.º 15
0
 public function index()
 {
     $comments = Comment::where('valid', '1')->get();
     return view('comments.index')->with(compact('comments'));
 }
Ejemplo n.º 16
0
 /**
  * Destroy a post if it exists.
  *
  * @param  $id
  * @return Response
  */
 public function destroy($id)
 {
     $post = Post::findOrFail($id);
     $post::destroy($id);
     // Delete comments whos post_id matches the current post that is being deleted
     Comment::where('post_id', '=', $id)->delete();
     return redirect()->action('PostController@index');
 }
 /**
  * -------------------------------------------
  * 查询某篇文章或某个商品下的评论
  * -------------------------------------------
  */
 public function commentList($post_id, $type)
 {
     $comments = Comment::where(['post_id' => $post_id, 'type' => $type])->paginate(10);
     return view('admin.comments.list')->with('comments', $comments);
 }
Ejemplo n.º 18
0
 /**
  * coupon function.
  * 
  * @access public
  * @param int $limit (default: 10)
  * @description Devuelve los datos de un cupon
  * @return void
  */
 public function getCoupon($id = 0)
 {
     $coupon = Coupon::leftJoin('categories', 'coupons.category_id', '=', 'categories.id')->leftJoin('coupons_premium', 'coupons_premium.coupon_id', '=', 'coupons.id')->where('coupons.id', '=', $id)->get(array('coupons.id', 'coupons.title', 'categories.name as category', 'coupons.description', 'coupons.restriction', 'coupons.latitude', 'coupons.longitude', DB::raw('IF(coupons_premium.coupon_id, 1, 0) AS premium')))->toArray();
     if (count($coupon) == 0) {
         return Response::json(array());
     }
     $coupon = $coupon[0];
     $coupon['ratings'] = (double) Rating::where("coupon_id", "=", $coupon['id'])->avg('value');
     $coupon['redems'] = (double) Scan::where("coupon_id", "=", $coupon['id'])->count();
     $coupon['comments'] = (double) Comment::where("coupon_id", "=", $coupon['id'])->where("disabled", "=", 0)->count();
     return Response::json($coupon);
 }
Ejemplo n.º 19
0
 public function postFastDelete($elements, Request $request)
 {
     switch ($elements) {
         case 'videos':
             $elements = $request->input('elements');
             $elements = explode(' ', $elements);
             PHPRedis::delete($elements);
             foreach ($elements as $element) {
                 // delete video from database
                 $elemId = Video::find($element);
                 if (!is_null($elemId)) {
                     $elemId->delete();
                 }
                 // delete folder
                 $destination = public_path("users_content/videos/{$element}");
                 if (File::exists($destination)) {
                     File::deleteDirectory($destination);
                 }
                 // delete comments from database
                 Comment::where('video_id', $element)->delete();
             }
             return redirect()->back()->with('message_success', 'Elements have been deleted');
             break;
         case 'users':
             $elements = $request->input('elements');
             $elements = explode(' ', $elements);
             foreach ($elements as $element) {
                 $elem = User::find($element);
                 if (!is_null($elem)) {
                     $elem->delete();
                 }
             }
             return redirect()->back()->with('message_success', 'Elements have been deleted');
             break;
         default:
             $elements = $request->input('elements');
             $elements = explode(' ', $elements);
             foreach ($elements as $element) {
                 $elem = Comment::find($element);
                 if (!is_null($elem)) {
                     $elem->delete();
                 }
             }
             return redirect()->back()->with('message_success', 'Elements have been deleted');
             break;
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     Comment::where('page_id', $id)->first();
 }
Ejemplo n.º 21
0
 public function rating()
 {
     return number_format(Comment::where('product_id', '=', $this->id)->avg('rating'), 2);
 }
Ejemplo n.º 22
0
 public function commentDelete($id)
 {
     $comment = Comment::where('id', $id)->delete();
     return redirect(route("comments"));
 }
Ejemplo n.º 23
0
 public function getChiTiet($id)
 {
     $brands = $this->brands;
     $socho = $this->sochoxe;
     $tintucs = $this->tintucs;
     $binhluans = Comment::where('xe_id', $id)->orderBy('id', 'desc')->paginate(3);
     foreach ($binhluans as $key => $value) {
         if ($value->nguoidung_id != NULL) {
             $user = User::where('nguoidung_id', $value->nguoidung_id)->get()->first();
             $value->nguoidung_id = $user->tendaydu;
         }
     }
     //dd($binhluans);
     // xe hiện tại
     $xe = Cars::where('xe_id', $id)->get()->first();
     // tên lái xe theo xe
     $tenlaixe = TaiXe::where('taixe_id', $xe->tai_xe_id)->get()->first();
     $xekhac = Cars::whereNotIn('xe_id', [$id])->where(function ($query) use($xe) {
         $query->where('socho_xe', $xe->socho_xe)->orWhere('hang_id', $xe->hang_id);
     })->get();
     //dd($xekhac);
     //dd($xe); die();
     $vote_id = Vote::where('cars_id', $id)->get()->first();
     if ($vote_id->sovotes != 0) {
         $roundVote = round($vote_id->tongdiem / $vote_id->sovotes, 1);
     } else {
         $roundVote = 0;
     }
     //dd($vote_id);
     return view('frontend.pages.chitiet', compact('vote_id', 'binhluans', 'xe', 'socho', 'brands', 'tintucs', 'tenlaixe', 'xekhac', 'roundVote'));
 }
Ejemplo n.º 24
0
 public function list_comment($param = null)
 {
     $rs = Comment::where("comment_blogs_id", $param)->get();
     echo json_encode($rs);
 }
Ejemplo n.º 25
0
 public static function deleteCommentEvent($comment_event_id)
 {
     $result = Comment::where('comment_event_id', $comment_event_id)->first();
     return $result;
 }
Ejemplo n.º 26
0
 public function removeComment($commentID, $cardID)
 {
     if (!Auth::check()) {
         return redirect("/");
     }
     $delChecklist = Comment::where('id', '=', $commentID);
     $delChecklist->delete();
     $card = Card::with(['checklists', 'memberCard.member', 'comments.memberComment', 'preCard'])->find($cardID);
     return $card;
 }
Ejemplo n.º 27
0
 /**
  * Get load more product comments
  *
  * @param int $productId
  * @param int $before
  *
  * @return App\Models\Comment
  */
 protected function _getLoadMoreComents($productId, $before = 0)
 {
     $comment = Comment::where('product_id', $productId);
     if ($before) {
         $comment->where('id', '<', $before);
     }
     return $comment->orderBy('id', 'DESC');
 }
Ejemplo n.º 28
0
 public function get_userinfo()
 {
     $project_id = $this->project_id;
     $page_id = $this->page_id;
     $uid = Input::get('user_id');
     $data = Comment::where('project_id', $project_id)->where('page_id', $page_id)->where('user_id', $uid)->orderBy('id', 'desc')->first();
     if ($data) {
         $return_data['status'] = 0;
         $return_data['data'][] = array_merge($data->Extend->toArray(), $data->toArray());
     } else {
         $return_data['status'] = 0;
         $return_data['data'] = array();
     }
     return $this->_return_json($return_data);
 }