コード例 #1
0
 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
0
ファイル: CommentTest.php プロジェクト: richardlawson/gcblog
 public function testToArray()
 {
     $blogEntry = new BlogEntry(array('id' => 1));
     $comment = new Comment(array('id' => 5, 'postDate' => new \DateTime('2011-10-30'), 'name' => 'richard', 'email' => '*****@*****.**', '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('*****@*****.**', $commentAsArray['email']);
     $this->assertEquals('hello world', $commentAsArray['content']);
 }
コード例 #3
0
 /**
  * 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
0
 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
0
 /**
  *	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
0
ファイル: Issue.php プロジェクト: k127/donedone-api-php
 /**
  * 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());
 }