Esempio n. 1
0
 /**
  * Get the post results, ready to be serialized and assigned to the
  * document response.
  *
  * @param \Flarum\Api\JsonApiRequest $request
  * @param \Flarum\Api\JsonApiResponse $response
  * @return \Illuminate\Database\Eloquent\Collection
  */
 protected function data(JsonApiRequest $request, JsonApiResponse $response)
 {
     $postIds = (array) $request->get('ids');
     $user = $request->actor->getUser();
     if (count($postIds)) {
         $posts = $this->posts->findByIds($postIds, $user);
     } else {
         if ($discussionId = $request->get('discussions')) {
             $where['discussion_id'] = $discussionId;
         }
         if ($number = $request->get('number')) {
             $where['number'] = $number;
         }
         if ($userId = $request->get('users')) {
             $where['user_id'] = $userId;
         }
         $posts = $this->getPosts($request, $where);
     }
     return $posts;
 }
Esempio n. 2
0
 /**
  * Get a single post, ready to be serialized and assigned to the JsonApi
  * response.
  *
  * @param \Flarum\Api\JsonApiRequest $request
  * @param \Flarum\Api\JsonApiResponse $response
  * @return \Flarum\Core\Models\Discussion
  */
 protected function data(JsonApiRequest $request, JsonApiResponse $response)
 {
     return $this->posts->findOrFail($request->get('id'), $request->actor->getUser());
 }