本文整理汇总了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());
}
示例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']);
}
示例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));
}
示例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);
}
示例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));
}
示例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());
}