/**
  * Handle the report moment command.
  *
  * @param \Gitamin\Commands\Moment\AddMomentCommand $command
  *
  * @return \Gitamin\Models\Moment
  */
 public function handle(AddMomentCommand $command)
 {
     $data = ['action' => $command->action, 'author_id' => $command->author_id];
     if ($command->title) {
         $data['title'] = $command->title;
     }
     if ($command->data) {
         $data['data'] = $command->data;
     }
     // Link with the target.
     if ($command->target_type) {
         $data['target_type'] = $command->target_type;
     }
     if ($command->target_id) {
         $data['target_id'] = $command->target_id;
     }
     // Link with the project.
     if ($command->project_id) {
         $data['project_id'] = $command->project_id;
     }
     // Create the moment
     $moment = Moment::create($data);
     //event(new MomentWasAddedEvent($moment));
     return $moment;
 }
 /**
  * Trigger the moment.
  *
  * @param \Gitamin\Models\Comment $comment
  * @param int                     $action
  */
 protected function trigger(Owner &$owner, $action)
 {
     $data = ['target_type' => 'Owner', 'target_id' => $owner->id, 'action' => $action, 'author_id' => $owner->user_id, 'project_id' => 0];
     $moment = Moment::create($data);
 }
 /**
  * Trigger the moment.
  *
  * @param \Gitamin\Models\Project $project
  * @param int                     $action
  */
 protected function trigger(Project &$project, $action)
 {
     $data = ['target_type' => 'Project', 'target_id' => $project->id, 'action' => $action, 'author_id' => $project->creator_id, 'project_id' => $project->id];
     $moment = Moment::create($data);
 }
 /**
  * Seed the comments table.
  */
 protected function seedMoments()
 {
     $defaultMoments = [['message' => ':+1: We totally nailed the fix.', 'momentable_type' => 'Gitamin\\Models\\Issue', 'momentable_id' => 3, 'action' => Moment::COMMENTED, 'author_id' => 1, 'project_id' => 1], ['message' => ":ship: We've deployed a fix.", 'momentable_type' => 'Gitamin\\Models\\Issue', 'momentable_id' => 2, 'action' => Moment::CREATED, 'author_id' => 1, 'project_id' => 2]];
     foreach ($defaultMoments as $moment) {
         Moment::create($moment);
     }
 }
 /**
  * Trigger the moment.
  *
  * @param \Gitamin\Models\Comment $comment
  * @param int                     $action
  */
 protected function trigger(Comment &$comment, $action)
 {
     $data = ['target_type' => 'Comment', 'target_id' => $comment->id, 'action' => $action, 'author_id' => $comment->author_id, 'project_id' => $comment->project_id];
     $moment = Moment::create($data);
 }