/** * 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); }
/** * Get an empty entity, apply the payload. * * @return Entity */ protected function getEntity() { return $this->repo->getEntity()->setState($this->payload); }
/** * 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); }