public function getSingleStory($id) { $result = $this->storyStoryRepository->findStoryById($id); if (!$result) { return null; } $result['cover_img'] = json_decode($result['cover_img']); $result['comment_count'] = (int) $result['comment_count']; return $result; }
public function getAllStories($page, $limit, $listing_type) { if ($listing_type === 'public') { $visible_for = 0; } else { if ($listing_type === 'all') { $visible_for = NULL; //We will show all records // TODO: not all, public + logged user listings } else { if ($listing_type === 'wall') { $visible_for = 1; //check user } } } $offset = $page * $limit - $limit; $results = $this->storyStoryRepository->findAllStories($offset, $limit, $visible_for); foreach ($results['data'] as $k => $result) { $results['data'][$k]['cover_img'] = json_decode($result['cover_img']); } return $results; }