本文整理汇总了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);
}
示例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);
}
示例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');
}
}
示例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');
}
示例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);
}
示例6: destroy
public function destroy($id)
{
$status = Comment::find($id);
$status->delete();
Flash::message('Your comment has been deleted.');
return Redirect::back();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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'));
}
示例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));
}
示例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')));
}
示例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;
}
示例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;
}
}
示例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!');
}