laravel modify all json responses
public function handle($request, Closure $next)
{
// get response
$response = $next($request);
// if response is JSON
if($response instanceof JsonResponse){
$current_data = $response->getData();
$current_data->userData = ['attach some additional user data'];
$response->setData($current_data);
}
return $response;
}