public function showJson($id)
{
// should top timeouts on long queries
set_time_limit(0);
$opts = $this->getOptions();
$model = $this->repo->show($id, $opts);
return IlluminateResponse::stream(function () use($model, $opts) {
if (ob_get_level() == 0) {
ob_start();
}
echo '[';
$this->repo->export($model, array_merge($opts, ['next' => function () {
echo ',';
flush();
ob_flush();
}, 'stream' => function ($obj) {
echo json_encode($obj);
}]));
echo ']';
}, 200, ['Content-Type' => 'application/json']);
}