當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。