Skip to content

Instantly share code, notes, and snippets.

@kkz6
Created June 14, 2023 07:08
Show Gist options
  • Select an option

  • Save kkz6/e0e3d1d59754972e89796d8fb4026159 to your computer and use it in GitHub Desktop.

Select an option

Save kkz6/e0e3d1d59754972e89796d8fb4026159 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\JsonResponse;
class ProfileJsonResponse
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$response = $next($request);
if (
$response instanceof JsonResponse &&
app()->bound('debugbar') &&
app('debugbar')->isEnabled() &&
is_object($response->getData())
) {
$response->setData($response->getData(true) + [
'_debugbar' => app('debugbar')->getData(),
]);
}
return $response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment