我在Fractal库中遇到问题。我正在使用Spatie \ laravel-fractal库,它只是League \ fractal的包装。所以...
我想返回一个空对象而不是一个空数组。
public function includeDocumentType(Question $question)
{
return $question->documentType
? $this->item($question->documentType, new DocumentTypeTransformer)
: $this->null();
}
$this->null()
总是[]
在一代之后回来,我想回来{}
。我想拥有2个功能,例如$this->nullItem()
和$this->nullCollection()
。
有谁知道该问题的解决方案是什么?
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句