Laravel Fractal не возвращает мета из отношения включения

Это мое PostTransformer где я включил отношения

public function includeComments(Post $post)
{
    if (($post->is_paid == 1 && $post->haspaid == 1) || ($post->author == $this->params) || ($post->is_paid == 0)){
        $comments = Comment::where('post', $post->id)
            ->where('is_blocked', '=', 0)
            ->select('id',
                'text',
                'author',
                'post',
                'created_at',
                'updated_at',
                'book_id',
                DB::raw("if(comments.author=$this->params,'true','false') as isauthor"))
            ->orderBy('created_at', 'ASC')
            ->paginate(5);
        $commentTransformer = new CommentTransformer($this->params);
        $commentResource = $this->collection($comments, $commentTransformer, 'comment')->setMeta(['total'=>count($comments)]);
        return $commentResource;
    } elseif ($post->is_paid == 1 && $post->haspaid == 0) {
        return $this->null();
    }

}

Это должно привести к связи комментариев с мета. Но проблема здесь в том, что я не получил мета в неразрывных отношениях. Если кто-то может помочь мне в этом.

1 ответ

Это известная проблема с фракталом.

вопрос

https://github.com/thephpleague/fractal/issues/339

Запрос на тягу (открытый)

Есть открытый запрос на включение meta для отношений.

https://github.com/thephpleague/fractal/pull/350

Другие вопросы по тегам