当前位置: 首页>>代码示例>>PHP>>正文


PHP Comment::find方法代码示例

本文整理汇总了PHP中Comment::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::find方法的具体用法?PHP Comment::find怎么用?PHP Comment::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Comment的用法示例。


在下文中一共展示了Comment::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCommentFind

 /**
  * testCommentFind
  *
  * @return void
  */
 public function testCommentFind()
 {
     $this->Comment->recursive = -1;
     $results = $this->Comment->find('first');
     $this->assertTrue(!empty($results));
     $expected = array('Comment' => array('id' => '1', 'user_id' => null, 'model' => 'Article', 'foreign_key' => '1', 'parent_id' => '0', 'approved' => 1, 'name' => null, 'title' => '-', 'slug' => '_', 'body' => 'This is a comment', 'lft' => 1, 'rght' => 2, 'modified' => '2008-12-22 16:39:19', 'created' => '2008-12-22 16:39:19', 'author_name' => 'mark story', 'author_email' => 'example@example.com', 'author_url' => 'http://example.com', 'is_spam' => 'clean', 'comment_type' => 'comment'));
     $this->assertEqual($results, $expected);
 }
开发者ID:rodrigorm,项目名称:comments,代码行数:13,代码来源:CommentTest.php

示例2: testProcessDisapprove

 /**
  * testProcessDisapprove
  *
  * @return void
  */
 public function testProcessDisapprove()
 {
     $data['Comment'] = array('1' => 1, '2' => 0);
     $this->Comment->process('disapprove', $data);
     $comment = $this->Comment->find('first', array('conditions' => array('Comment.id' => 1)));
     $this->assertEqual($comment['Comment']['approved'], false);
 }
开发者ID:radig,项目名称:comments,代码行数:12,代码来源:CommentTest.php

示例3: postPostscustom

 public function postPostscustom()
 {
     $postsCheked = Input::get('comments');
     if (is_array($postsCheked)) {
         $customposts = Input::get('customposts');
         if ($customposts == 'publish') {
             for ($i = 0; $i < count($postsCheked); $i++) {
                 if (Comment::find($postsCheked[$i])->status == '0') {
                     DB::table('comments')->where('id', $postsCheked[$i])->update(['status' => 1]);
                 }
             }
             return Redirect::to('/teacher/comments');
         } else {
             if ($customposts == 'unpublish') {
                 for ($i = 0; $i < count($postsCheked); $i++) {
                     if (Comment::find($postsCheked[$i])->status == '1') {
                         DB::table('comments')->where('id', $postsCheked[$i])->update(['status' => 0]);
                     }
                 }
                 return Redirect::to('/teacher/comments');
             } else {
                 if ($customposts == 'delete') {
                     for ($i = 0; $i < count($postsCheked); $i++) {
                         Comment::find($postsCheked[$i])->delete();
                     }
                     return Redirect::to('/teacher/comments');
                 } else {
                     return Redirect::to('/teacher/comments');
                 }
             }
         }
     } else {
         return Redirect::to('/teacher/comments');
     }
 }
开发者ID:resethread,项目名称:elycee,代码行数:35,代码来源:CommentsController.php

示例4: post_edit

 public function post_edit()
 {
     if (!cmsHelper::isCurrentUserAllowedToPerform('comments')) {
         return;
     }
     //Flash current values to session
     Input::flash();
     $id = Input::get('editingMode');
     $editComment = Comment::find($id);
     $editComment->name = Input::get('name');
     $editComment->email = Input::get('email');
     $editComment->content = Input::get('content');
     //Add rules here
     $rules = array('name' => 'required', 'email' => 'required', 'content' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     //Validate rules
     if ($validation->fails()) {
         return Redirect::to($_SERVER['PATH_INFO'] . '?id=' . $editComment->id)->with_errors($validation);
     }
     //Update the comment
     $editComment->save();
     return Redirect::to($_SERVER['PATH_INFO'] . '?id=' . $editComment->id)->with('successmessage', 'Comment successfully updated');
 }
开发者ID:gischen,项目名称:PHP-CMS,代码行数:26,代码来源:comments.php

示例5: actionAdmin

 public function actionAdmin()
 {
     // delete comment request
     if (Rays::isPost()) {
         if (isset($_POST['checked_comments'])) {
             $commentIds = $_POST['checked_comments'];
             foreach ($commentIds as $id) {
                 if (!is_numeric($id)) {
                     return;
                 } else {
                     $comment = new Comment();
                     $comment->id = $id;
                     $comment->delete();
                 }
             }
         }
     }
     $curPage = $this->getPage("page");
     $pageSize = $this->getPageSize('pagesize', 10);
     $count = Comment::find()->count();
     $comments = Comment::find()->join("user")->join("topic")->order_desc("id")->range(($curPage - 1) * $pageSize, $pageSize);
     $pager = new RPager('page', $count, $pageSize, RHtml::siteUrl('comment/admin'), $curPage);
     $this->layout = 'admin';
     $this->setHeaderTitle("Comments administration");
     $data = array('count' => $count, 'comments' => $comments, 'pager' => $pager->showPager());
     $this->render('admin', $data, false);
 }
开发者ID:a4501150,项目名称:FDUGroup,代码行数:27,代码来源:CommentController.php

示例6: destroy

 public function destroy($id)
 {
     $status = Comment::find($id);
     $status->delete();
     Flash::message('Your comment has been deleted.');
     return Redirect::back();
 }
开发者ID:jamalots,项目名称:jamalot.dev,代码行数:7,代码来源:CommentsController.php

示例7: testCounterIncrementsAndDecrementsWhen

 public function testCounterIncrementsAndDecrementsWhen()
 {
     $post_with_comments = new Post();
     $post_with_comments->title = 'post 1';
     $this->assertTrue($post_with_comments->save());
     $post_without_comments = new Post();
     $post_without_comments->title = 'post 2';
     $this->assertTrue($post_without_comments->save());
     //Create 10 comments, ensure counter increments
     for ($i = 1; $i <= 10; $i++) {
         $comment = new Comment();
         $comment->postId = $post_with_comments->id;
         $comment->text = 'comment ' . $i;
         $this->assertTrue($comment->save());
         $post_with_comments->refresh();
         $post_without_comments->refresh();
         $this->assertEquals($post_with_comments->commentsCount, $i);
         $this->assertEquals($post_without_comments->commentsCount, 0);
     }
     //Delete all comments, ensure counter decrements
     $comments = Comment::find()->all();
     $count = count($comments);
     foreach ($comments as $comment) {
         $this->assertEquals($comment->delete(), 1);
         $count--;
         $post_with_comments->refresh();
         $this->assertEquals($post_with_comments->commentsCount, $count);
     }
 }
开发者ID:ostapetc,项目名称:yii2-cache-counter-behavior,代码行数:29,代码来源:CounterCacheBehaviorTest.php

示例8: findById

 public function findById($post_id, $id)
 {
     $comment = Comment::find($id);
     if (!$comment || $comment->post_id != $post_id) {
         throw new NotFoundException('Comment Not Found');
     }
     return $comment;
 }
开发者ID:valdinei,项目名称:nettuts-laravel4-and-backbone,代码行数:8,代码来源:EloquentCommentRepository.php

示例9: findParent

 /**
  * Find comment parent by id.
  * 
  * @param  int  $id
  * @return \FIIP\Comments\Comment|null
  */
 public function findParent($id)
 {
     $comment = Comment::find($id);
     if ($comment && $comment->parent) {
         return $this->findParent($comment->parent->id);
     }
     return $comment;
 }
开发者ID:adriancatalinsv,项目名称:fiip,代码行数:14,代码来源:CommentRepository.php

示例10: edit

 /**
  * Show the form for editing the specified comment.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $comment = Comment::find($id);
     if (Auth::id() != $comment->user_id) {
         return Redirect::action('comments.index');
     }
     return View::make('comments.edit', compact('comment'));
 }
开发者ID:automotivecapstone,项目名称:capstone.dev,代码行数:14,代码来源:CommentsController.php

示例11: destroy

 public function destroy($id)
 {
     $comment = Comment::find($id);
     if (!$comment->hasDefaultPhoto()) {
         File::delete($comment->fullPhotoPath());
     }
     Comment::destroy($id);
     return Response::json(array('success' => true));
 }
开发者ID:spinybeast,项目名称:cyclone-music-space.ru,代码行数:9,代码来源:CommentController.php

示例12: deleteIndex

 /**
  * Remove the specified resource from storage.
  *
  * @param $comment
  * @return Response
  */
 public function deleteIndex($comment)
 {
     $id = $comment->id;
     if (!$comment->delete()) {
         return Api::json(array('result' => 'error', 'error' => Lang::get('core.delete_error')));
     }
     $comment = Comment::find($id);
     return empty($comment) ? Api::json(array('result' => 'success')) : Api::json(array('result' => 'error', 'error' => Lang::get('core.delete_error')));
 }
开发者ID:Aranjedeath,项目名称:l4-starter,代码行数:15,代码来源:AdminCommentsController.php

示例13: getComments

 public function getComments()
 {
     $comments = Comment::find(array("topicId", $this->id, "pid", 0))->all();
     $result = [];
     foreach ($comments as $c) {
         $result[] = ['root' => $c, 'reply' => $c->children()];
     }
     return $result;
 }
开发者ID:a4501150,项目名称:FDUGroup,代码行数:9,代码来源:Topic.php

示例14: actionDelete

 public function actionDelete($id)
 {
     if ($_POST['action'] == 1) {
         $model = Comment::find($id);
         $model->delete();
         echo json_encode(array('id' => array($id), 'class' => 'alert-success', 'message' => __('delete success')));
         exit;
     }
 }
开发者ID:rocketyang,项目名称:mincms,代码行数:9,代码来源:SiteController.php

示例15: delete_destroy

 public function delete_destroy()
 {
     $cid = Input::get('cid');
     $pid = Input::get('pid');
     $post = Post::find($pid);
     //$post_id = Comment::find(Input::get('id'))->post->slug;
     Comment::find($cid)->delete();
     return Redirect::to_route('post_view', $post->slug)->with('message', 'Comment has been deleted Successfully!');
 }
开发者ID:reeceballano,项目名称:Mayaten-Blog,代码行数:9,代码来源:comments.php


注:本文中的Comment::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。