/**
  * Create post for message
  * @param  Entity $message
  * @return Int
  */
 protected function createPost(Entity $message)
 {
     $values = [];
     // Pull locations from extra metadata
     if ($message->additional_data) {
         $values['message_location'] = [];
         foreach ($message->additional_data['location'] as $location) {
             if (!empty($location['type']) && !empty($location['coordinates']) && ucfirst($location['type']) == 'Point') {
                 $values['message_location'][] = ['lon' => $location['coordinates'][0], 'lat' => $location['coordinates'][1]];
             }
         }
     }
     // First create a post
     $post = $this->postRepo->getEntity()->setState(['title' => $message->title, 'content' => $message->message, 'values' => $values]);
     return $this->postRepo->create($post);
 }
Example #2
0
 /**
  * Get the created entity.
  *
  * @param  Mixed $id
  * @return Entity
  */
 protected function getCreatedEntity($id)
 {
     return $this->repo->get($id);
 }
Example #3
0
 /**
  * Create post for message
  * @param  Entity $message
  * @return Int
  */
 protected function createPost(Entity $message)
 {
     // First create a post
     $post = $this->postRepo->getEntity()->setState(['title' => $message->title, 'content' => $message->message]);
     return $this->postRepo->create($post);
 }