From e32f26d048249b84166542d6442efdf202ff44fd Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 23 May 2015 21:44:33 -0400 Subject: API refactoring --- app/Api/Comment.php | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 app/Api/Comment.php (limited to 'app/Api/Comment.php') diff --git a/app/Api/Comment.php b/app/Api/Comment.php new file mode 100644 index 00000000..19b84383 --- /dev/null +++ b/app/Api/Comment.php @@ -0,0 +1,51 @@ +comment->getById($comment_id); + } + + public function getAllComments($task_id) + { + return $this->comment->getAll($task_id); + } + + public function removeComment($comment_id) + { + return $this->comment->remove($comment_id); + } + + public function createComment($task_id, $user_id, $content) + { + $values = array( + 'task_id' => $task_id, + 'user_id' => $user_id, + 'comment' => $content, + ); + + list($valid,) = $this->comment->validateCreation($values); + + return $valid ? $this->comment->create($values) : false; + } + + public function updateComment($id, $content) + { + $values = array( + 'id' => $id, + 'comment' => $content, + ); + + list($valid,) = $this->comment->validateModification($values); + return $valid && $this->comment->update($values); + } +} -- cgit v1.2.3