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


PHP Post::comments方法代码示例

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


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

示例1: getIndex

 /**
  * Returns all the blog posts.
  *
  * @return View
  */
 public function getIndex()
 {
     // Get all the blog posts
     $posts = $this->post->orderBy('created_at', 'DESC')->paginate(10);
     $comments = $this->post->comments();
     // Show the page
     return View::make('site/blog/index', compact('posts'), compact('comments'));
 }
开发者ID:ColErr,项目名称:creepr-workbench,代码行数:13,代码来源:BlogController.php

示例2: run

    public function run()
    {
        $content = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.
		Praesent vel ligula scelerisque, vehicula dui eu, fermentum velit.
		Phasellus ac ornare eros, quis malesuada augue. Nunc ac nibh at mauris dapibus fermentum.
		In in aliquet nisi, ut scelerisque arcu. Integer tempor, nunc ac lacinia cursus,
		mauris justo volutpat elit,
		eget accumsan nulla nisi ut nisi. Etiam non convallis ligula. Nulla urna augue,
		dignissim ac semper in, ornare ac mauris. Duis nec felis mauris.';
        for ($i = 1; $i <= 20; $i++) {
            $post = new Post();
            $post->title = "Post no {$i}";
            $post->read_more = substr($content, 0, 120);
            $post->content = $content;
            $post->save();
            $maxComments = mt_rand(3, 15);
            for ($j = 1; $j <= $maxComments; $j++) {
                $comment = new Comment();
                $comment->commenter = 'xyz';
                $comment->comment = substr($content, 0, 120);
                $comment->email = 'xyz@xmail.com';
                $comment->approved = 1;
                $post->comments()->save($comment);
                $post->increment('comment_count');
            }
        }
    }
开发者ID:rituzy,项目名称:iblog,代码行数:27,代码来源:PostCommentSeeder.php

示例3: displayPost

 public function displayPost(Post $post)
 {
     $previousPost = Post::where('draft', '=', 0)->where('id', '<', $post->id)->max('id');
     $nextPost = Post::where('draft', '=', 0)->where('id', '>', $post->id)->min('id');
     if (!is_null($previousPost)) {
         $previousPostTitle = Post::find($previousPost)->title;
     }
     if (!is_null($nextPost)) {
         $nextPostTitle = Post::find($nextPost)->title;
     }
     $comments = $post->comments()->where('approved', '=', 1)->get();
     $this->layout->title = $post->title;
     $this->layout->main = View::make('home')->nest('content', 'posts.show', compact('post', 'comments', 'previousPost', 'nextPost', 'nextPostTitle', 'previousPostTitle'));
 }
开发者ID:jeremy6680,项目名称:easy-peasy-cms,代码行数:14,代码来源:HomeController.php

示例4: newComment

 public function newComment(Post $post)
 {
     $comment = ['commenter' => Input::get('commenter'), 'email' => Input::get('email'), 'comment' => Input::get('comment')];
     $rules = ['commenter' => 'required', 'email' => 'required | email', 'comment' => 'required'];
     $valid = Validator::make($comment, $rules);
     if ($valid->passes()) {
         $comment = new Comment($comment);
         $comment->approved = 'no';
         $post->comments()->save($comment);
         /* redirect back to the form portion of the page */
         return Redirect::to(URL::previous() . '#reply')->with('success', 'Comment has been submitted and waiting for approval!');
     } else {
         return Redirect::to(URL::previous() . '#reply')->withErrors($valid)->withInput();
     }
 }
开发者ID:Neal-liu,项目名称:neal-liu.github.io,代码行数:15,代码来源:CommentController.php

示例5: showPost

 public function showPost(Post $post)
 {
     $comments = $post->comments()->where('approved', '=', 1)->get();
     $this->layout->title = $post->title;
     $this->layout->main = View::make('home')->nest('content', 'posts.single', compact('post', 'comments'));
 }
开发者ID:singh7889,项目名称:Laravel-blog-post,代码行数:6,代码来源:PostController.php

示例6: array

    $xid = $_GET['xid'];
    $url = $_GET['url'];
} else {
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        $xid = $_POST['xid'];
        $url = $_POST['url'];
        $fb_prefix = $_POST['fb_prefix'];
    }
}
$params = array();
$params['xid'] = $xid;
$params['permalink'] = $url;
if (array_key_exists('fb_prefix', $_GET)) {
}
$entry = new Post($_GET);
$comments = $entry->comments();
?>

</head>
<body>
   
<h2>TypePad Comment Listing.</h2>

<?php 
foreach ($comments as $comment) {
    echo '   <div class="comment-outer">
      <div class="comment-avatar">
         <a href="' . $comment->author->profile_url . '"><img class="avatar" src="' . $comment->author->avatar . '" /></a>
      </div>
      <div class="comment-contents">
         <a href="' . $comment->author->profile_url . '">' . $comment->author->display_name . '</a>
开发者ID:nataliepo,项目名称:Rousseau,代码行数:31,代码来源:typepad_comments.php

示例7: newCommentReg

 public function newCommentReg(Post $post)
 {
     $inputs = ['user_id' => Input::get('uid'), 'comment' => Input::get('comment'), 'image' => Input::file('image'), 'name' => Input::get('tag')];
     $attributeNames = ['name' => 'Tag name'];
     $valid = Validator::make($inputs, Comment::$rulesReg);
     $valid->setAttributeNames($attributeNames);
     $valid->sometimes('name', 'unique:tags|min:3|max:12', function ($inputs) {
         return !is_numeric($inputs['name']);
     });
     if ($valid->passes()) {
         $comment = new Comment();
         //uncomment the string below to use comment checking by administrator
         //$comment->approved = 0;//'no';
         $comment->commenter = '';
         $comment->email = '';
         $comment->user_id = $inputs['user_id'];
         $comment->comment = $inputs['comment'];
         $tag = $inputs['name'];
         $image = $inputs['image'];
         if (isset($image)) {
             list($width, $height) = getimagesize($image);
             $ratio = $height / $width;
             $filename = date('Y-m-d-H:i:s') . "-" . $image->getClientOriginalName();
             $width = $width > 600 ? 600 : $width;
             $height = $height > 600 ? $width * $ratio : $height;
             Image::make($image->getRealPath())->resize($width, $height)->save(public_path() . '/img/pncpictures/' . $filename);
             $comment->image = 'img/pncpictures/' . $filename;
         } else {
             $comment->image = '';
         }
         if ($tag != 'default') {
             $comment->addTagOrCreateNew($tag, $inputs['user_id']);
         }
         $post->comments()->save($comment);
         $comment->updateComment(1);
         /* redirect back to the form portion of the page */
         return Redirect::to(URL::previous() . '#reply')->with('success', trans('messages.CHBS'));
     } else {
         return Redirect::to(URL::previous() . '#reply')->withErrors($valid)->withInput();
     }
 }
开发者ID:rituzy,项目名称:iblog,代码行数:41,代码来源:CommentController.php

示例8: Post

      MTConnect Blog:
         http://localhost/rousseau/generic_fb_app/comments.php?blog_xid=6a00e5539faa3b88330120a94362b9970b&permalink=http://mtcs-demo.apperceptive.com/testmt/animals/2010/03/sea-otter.php&fb_id=fb-animals-60
   
   
      MTConnectBlog:
         http://dev3.apperceptive.com/rousseau/comments.php?blog_xid=6a00e5539faa3b88330120a94362b9970b&permalink=http://mtcs-demo.apperceptive.com/testmt/animals/2010/03/sea-otter.php&fb_id=fb-animals-60&HTML=1
      
      Standard TypePad Blog:
         http://dev3.apperceptive.com/rousseau/comments.php?xid=6a00e5539faa3b883301310f284ed8970c&permalink=http://nataliepo.typepad.com/hobbitted/2010/02/some-ill-shit-is-overdue-in-the-hobbit-right-about-now.html&fb_prefix=braided_comments-&HTML=1

*/
require_once 'rousseau-includes/rousseau-utilities.php';
start_db_connection();
//$post = new Post($_POST);
$post = new Post($_GET);
$comments = $post->comments();
/*
debug ("<h2>GET table:</h2>");
print_as_table($_GET);
  
debug("<h2>POST table:</h2>");
print_as_table($_POST);
*/
//if (array_key_exists('HTML', $_POST)) {
if (array_key_exists('HTML', $_GET)) {
    foreach ($comments as $comment) {
        echo '   <div class="comment-outer">
         <div class="comment-avatar">
            <a href="' . $comment->author->profile_url . '"><img class="avatar" src="' . $comment->author->avatar . '" /></a>
         </div>
         <div class="comment-contents">
开发者ID:nataliepo,项目名称:Rousseau,代码行数:31,代码来源:comments.php

示例9: testCommentsIsAMorphMany

 public function testCommentsIsAMorphMany()
 {
     $post = new Post();
     $this->assertInstanceOf('Illuminate\\Database\\Eloquent\\Relations\\MorphMany', $post->comments());
 }
开发者ID:jackw899,项目名称:laravel-commentable,代码行数:5,代码来源:PostRelationsTest.php


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