Esempio n. 1
0
 /**
  * Create new comment
  *
  * @param array $input
  *
  * @return $this
  */
 public function createComment(array $input)
 {
     $fill = ['created_by' => $this->user->id, 'project_id' => $this->project->id, 'issue_id' => $this->issue->id, 'comment' => $input['comment']];
     $this->fill($fill);
     $this->save();
     /* Add to user's activity log */
     $this->activity()->save(new User\Activity(['type_id' => Activity::TYPE_COMMENT, 'parent_id' => $this->project->id, 'item_id' => $this->issue->id, 'user_id' => $this->user->id]));
     /* Add attachments to issue */
     Attachment::where('upload_token', '=', $input['upload_token'])->where('uploaded_by', '=', $this->user->id)->update(['issue_id' => $this->issue->id, 'comment_id' => $this->id]);
     /* Update the project */
     $this->issue->changeUpdatedBy($this->user->id);
     return $this;
 }
Esempio n. 2
0
 /**
  * Create a new issue.
  *
  * @param array $input
  *
  * @return CrudTrait
  */
 public function createIssue(array $input)
 {
     $fill = ['created_by' => $this->user->id, 'project_id' => $this->project->id, 'title' => $input['title'], 'body' => $input['body']];
     if ($this->user->permission('issue-modify')) {
         $fill['assigned_to'] = $input['assigned_to'];
         $fill['time_quote'] = $input['time_quote'];
     }
     $this->fill($fill)->save();
     /* Add to user's activity log */
     $this->activities()->save(new User\Activity(['type_id' => Activity::TYPE_CREATE_ISSUE, 'parent_id' => $this->project->id, 'user_id' => $this->user->id]));
     /* Add attachments to issue */
     Attachment::where('upload_token', '=', $input['upload_token'])->where('uploaded_by', '=', $this->user->id)->update(['issue_id' => $this->id]);
     // Create tags
     $tags = $this->createTags(array_map('trim', explode(',', $input['tag'])), $this->user->permission('administration'));
     $this->syncTags($tags);
     return $this;
 }