/** * Add a comment/reply to the review * * @return Response */ public function comment() { $me = Input::get('user'); $review = Input::get('review'); $comment = Input::get('comment'); // checking if reply already posted $check = DB::table('review_comments')->where('rc_user_id', $me)->where('rc_review_id', $review)->first(); // adding new comment $err = new Comment(); $err->rc_review_id = $review; $err->rc_user_id = $me; $err->rc_comment = $comment; $err->rc_date = \time(); $err->save(); // getting the user $user = DB::table('film_review')->where('fr_id', $review)->first(); // /* $reply = Comment::where('rc_user_id', $err->rc_user_id) ->where('rc_review_id', $err->rc_review_id) ->leftJoin('users','users.id','=','rc_user_id') ->orderBy('rc_date','desc') ->select('rc_id','rc_date','rc_comment','rc_review_id','rc_user_id','id','usr_fname','usr_lname','username','usr_image') ->first(); */ //$this->notification($me,$user,$review); //$this->replyMail($me, $user->fr_usr_id, $user->fr_fl_id, $user); //return View::make('admin.rev', compact('reply')); return Redirect::to(Config::get('url.home') . "admin/reviews"); }
public function getNew() { $comment = new Comment(); $comment->user_id = 1; $comment->title = md5(time() * rand()); $comment->content = md5(time() * rand()); $comment->link = ''; $comment->save(); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $posts = Post::orderBy('created_at', 'desc')->paginate(6, ['*'], 'p'); $comments = Comment::all(); $data = ['comments' => $comments, 'posts' => $posts]; return view('posts.index', $data); }
/** * 获取本节目的贡献者 * * @param int $date * @return array */ private function getProgramContributers($date) { $contributers = ['topic' => null, 'participants' => null]; $logs = Comment::contributed($date)->agreed()->get()->sortByDesc('id'); foreach ($logs as $log) { $author = ['name' => $log->metas->author_name, 'url' => $log->metas->author_url]; if (null === $contributers['topic'] and Comment::STATUS['ENABLE'] === $log->ext_has_topic) { $contributers['topic'] = $author; } if (null === $contributers['participants'] and Comment::STATUS['ENABLE'] === $log->ext_has_participant) { $contributers['participants'] = $author; } } return $contributers; }
/** * Count how many comments there are on a post. * * @param int $id * @return \Illuminate\Http\Response */ public function count($id) { $count = Comment::where('postid', $id)->count(); return $count; }
/** * 评论回调 * * @param Request $request * @return Response */ public function comment(Request $request) { // 验证签名 if (!$this->ds->checkSignature($request::all())) { return $this->output('Check signature faild.', true); } // 拉取最近一条日志 $lastLogId = Comment::getLastLogId(); $list = $this->ds->getLogList($lastLogId, 50); if (empty($list['response'])) { return $this->output('Empty response.', true); } // 遍历日志 foreach ($list['response'] as $log) { // 识别指令 $signs = Comment::ACTION['CREATE'] === $log['action'] ? Comment::recognizeCommands($log['meta']['message']) : []; // 记录日志 $id = Comment::import($log, $signs); // 通知 if (!empty($signs)) { // 回复评论 /* Comment::replyPost( '嗨,稍等一下哦~', $log['meta']['thread_id'], $log['meta']['post_id'], $log['meta']['author_email'] ); */ // 发送邮件 $log = $log + ['id' => $id]; $this->sendMail($log); } } $this->output('Success.', true); }