I'm having a problem with Fractal library. I'm using Spatie\laravel-fractal library which is just wrapper for League\fractal. So...
I want to return an empty object instead of an empty array.
public function includeDocumentType(Question $question)
{
return $question->documentType
? $this->item($question->documentType, new DocumentTypeTransformer)
: $this->null();
}
$this->null()
always returns []
after generation and I want to return {}
. Tbh I want to have 2 functions like $this->nullItem()
and $this->nullCollection()
.
Does anyone know what's the solution to this problem?