Created
June 14, 2023 07:08
-
-
Save kkz6/e0e3d1d59754972e89796d8fb4026159 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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