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


PHP Comment::toArray方法代码示例

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


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

示例1: postIndex

 public function postIndex($doc)
 {
     $comment = Input::get('comment');
     $newComment = new Comment();
     $newComment->user_id = Auth::user()->id;
     $newComment->doc_id = $comment['doc']['id'];
     $newComment->text = $comment['text'];
     $newComment->save();
     // Late load the user.
     $newComment->user;
     return Response::json($newComment->toArray());
 }
开发者ID:sethetter,项目名称:madison,代码行数:12,代码来源:CommentApiController.php

示例2: testToArray

 public function testToArray()
 {
     $blogEntry = new BlogEntry(array('id' => 1));
     $comment = new Comment(array('id' => 5, 'postDate' => new \DateTime('2011-10-30'), 'name' => 'richard', 'email' => 'lawson_richard@hotmail.com', 'content' => 'hello world', 'blogEntry' => $blogEntry));
     $commentAsArray = $comment->toArray();
     $this->assertEquals(5, $commentAsArray['id']);
     $this->assertEquals('30/10/2011', $commentAsArray['postDate']);
     $this->assertEquals('30/10/2011', $commentAsArray['postDateAsString']);
     $this->assertEquals('richard', $commentAsArray['name']);
     $this->assertEquals('lawson_richard@hotmail.com', $commentAsArray['email']);
     $this->assertEquals('hello world', $commentAsArray['content']);
 }
开发者ID:richardlawson,项目名称:gcblog,代码行数:12,代码来源:CommentTest.php

示例3: torrent

 /**
  * Ajoute un commentaire sur un torrent
  * 
  * @param $slug Slug du torrent
  * @param $id Id tu torrent
  */
 public function torrent($slug, $id)
 {
     $torrent = Torrent::find($id);
     $user = Auth::user();
     $comment = new Comment();
     $comment->content = Input::get('content');
     $comment->user_id = $user->id;
     $comment->torrent_id = $torrent->id;
     $v = Validator::make($comment->toArray(), array('content' => 'required', 'user_id' => 'required', 'torrent_id' => 'required'));
     if ($v->passes()) {
         $comment->save();
         Session::put('message', 'Your comment has been added');
     } else {
         Session::put('message', 'An error has occurred');
     }
     return Redirect::route('torrent', array('slug' => $torrent->slug, 'id' => $torrent->id));
 }
开发者ID:raphaeljorge,项目名称:tor,代码行数:23,代码来源:CommentController.php

示例4: store

 public function store()
 {
     $data = Input::all();
     $comment = new Comment();
     $comment['user_id'] = Session::get('user')['id'];
     $comment['content'] = $data['content'];
     $comment['entry_id'] = $data['entry_id'];
     $comment->save();
     if ($comment) {
         $user = $comment->user;
         $result = $comment->toArray();
         $result['status'] = 'success';
         $result['c_user_avatar'] = url($user->avatar);
         $result['c_user_fullname'] = $user->fullname;
         $result['c_user_path'] = url($user->account . '/profile');
     } else {
         $result['status'] = 'fail';
     }
     echo json_encode($result);
 }
开发者ID:huuson94,项目名称:WebProject,代码行数:20,代码来源:FECommentsController.php

示例5: onDocCommented

 /**
  *	Method for handling comment notifications
  *	
  *	@param Comment $data
  *	@return null
  */
 public function onDocCommented($data)
 {
     $notices = Notification::getActiveNotifications(MadisonEvent::DOC_COMMENTED);
     $notifications = $this->processNotices($notices, MadisonEvent::DOC_COMMENTED);
     $doc = Doc::find($data->doc_id);
     $this->doNotificationActions($notifications, array('data' => array('comment' => $data->toArray(), 'doc' => $doc->toArray()), 'subject' => "A new comment on a doc!", 'from_email_address' => static::FROM_EMAIL_ADDRESS, 'from_email_name' => static::FROM_EMAIL_NAME));
 }
开发者ID:iaincollins,项目名称:madison,代码行数:13,代码来源:NotificationEventHandler.php

示例6: addComment

 /**
  * Add a new comment to the issue
  *
  * @param Comment $comment
  *
  * @return array
  */
 public function addComment($comment)
 {
     return $this->client->post(sprintf('projects/%d/issues/%d/comments', $this->projectId, $this->id), $comment->toArray());
 }
开发者ID:k127,项目名称:donedone-api-php,代码行数:11,代码来源:Issue.php


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