Ejemplo n.º 1
0
 /**
  * Handle the report comment command.
  *
  * @param \Gitamin\Commands\Comment\AddCommentCommand $command
  *
  * @return \Gitamin\Models\Comment
  */
 public function handle(AddCommentCommand $command)
 {
     $data = ['message' => $command->message, 'commentable_type' => 'Gitamin\\Models\\' . $command->commentable_type, 'commentable_id' => $command->commentable_id];
     // Link with the user.
     if ($command->author_id) {
         $data['author_id'] = $command->author_id;
     }
     // Link with the project.
     if ($command->project_id) {
         $data['project_id'] = $command->project_id;
     }
     // Create the comment
     $comment = Comment::create($data);
     event(new CommentWasAddedEvent($comment));
     return $comment;
 }
Ejemplo n.º 2
0
 /**
  * Returns all comments of the issue.
  *
  * @return \Gitamin\Models\Comment[]
  */
 public function comments()
 {
     return Comment::where('target_type', '=', 'Issue')->where('target_id', '=', $this->id)->orderBy('id', 'asc')->get();
 }
Ejemplo n.º 3
0
 /**
  * Seed the comments table.
  */
 protected function seedComments()
 {
     $defaultComments = [['message' => ':+1: We totally nailed the fix.', 'commentable_type' => 'Gitamin\\Models\\Issue', 'commentable_id' => 3, 'author_id' => 1, 'project_id' => 1], ['message' => ":ship: We've deployed a fix.", 'commentable_type' => 'Gitamin\\Models\\MergeRequest', 'commentable_id' => 1, 'author_id' => 3, 'project_id' => 2], ['message' => "We've identified the problem. Our engineers are currently looking at it.", 'commentable_type' => 'Gitamin\\Models\\Issue', 'commentable_id' => 1, 'author_id' => 2, 'project_id' => 1], ['message' => 'Something went wrong, with something or another.', 'commentable_type' => 'Gitamin\\Models\\Issue', 'commentable_id' => 1, 'author_id' => 1, 'project_id' => 2], ['message' => ':zap: We\'ve seen high response times from our API. It looks to be fixing itself as time goes on.', 'commentable_type' => 'Gitamin\\Models\\MergeRequest', 'commentable_id' => 1, 'author_id' => 1, 'project_id' => 3]];
     foreach ($defaultComments as $comment) {
         Comment::create($comment);
     }
 }
Ejemplo n.º 4
0
 /**
  * Get all comments.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @param \Illuminate\Contracts\Auth\Guard          $auth
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function getComments(Request $request, Guard $auth)
 {
     $comments = Comment::paginate($request->input('per_page', 20));
     return $this->paginator($comments, $request);
 }