protected function response($data, $message = "", $code = 200)
    {
        $message = empty($message) ? [] : compact('message');

        return (request()->ajax() || request()->wantsJson())
            ? new JsonResponse($message + compact('data'), $code)
            : new Response($data, $code);
    }
protected function response($data, $message = "", $code = 200)
    {
        $message = empty($message) ? [] : compact('message');

        return (request()->ajax() || request()->wantsJson())
            ? new JsonResponse($message + compact('data'), $code)
            : new Response($data, $code);
    }
protected function response ( $ data , $ message = "" , $ code = 200 ) { $ message = empty ( $ message ) ? [ ] : compact ( 'message' ) ; return ( request ( ) -> ajax ( ) || request ( ) -> wantsJson ( ) ) ? new JsonResponse ( $ message + compact ( 'data' ) , $ code ) : new Response ( $ data , $ code ) ; }
Create a generic response.

@param  object  $data
@param  string  $message
@param  int  $code
@return JsonResponse|Response
Create a generic response .