response

The response function creates a response instance or obtains an instance of the response factory:
<?php return response('Hello World', 200, $headers);

return response()->json(['foo' => 'bar'], 200, $headers);
<?php             'root' => __DIR__,

        ]);



        return response()->download(

            Storage::disk('dusk-tmp')->path('download-target2.txt')

        );

    }
<?php             'root' => __DIR__,

        ]);



        return response()->download(

            Storage::disk('dusk-tmp')->path('download-target2.txt'),

            'download-target2.txt',

            ['Content-Type' => 'text/csv']
<?php             'root' => __DIR__,

        ]);



        return response()->download(

            Storage::disk('dusk-tmp')->path('download & target2.txt')

        );

    }
<?php         $lastModified = filemtime($file);



        return static::cachedFileResponse($file, $contentType, $lastModified,

            fn ($headers) => response()->file($file, $headers));

    }



    static function pretendPreviewResponseIsPreviewFile($filename)
<?php         $cacheControl = 'public, max-age=31536000';



        if (static::matchesCache($lastModified)) {

            return response('', 304, [

                'Expires' => static::httpDate($expires),

                'Cache-Control' => $cacheControl,

            ]);

        }



        $headers = [
<?php     public function streamDownload($filename = null, $headers = [])

    {

        $this->downloaded = true;

        return response()->streamDownload(function () {

            echo 'alpinejs';

        }, $filename, $headers);

    }
<?php         $layoutConfig->normalizeViewNameAndParamsForBladeComponents();



        $response = response(SupportPageComponents::renderContentsIntoLayout($html, $layoutConfig));



        if (is_callable($layoutConfig->response)) {

            call_user_func($layoutConfig->response, $response);
<?php     {

        if (static::$response) return;



        static::$response = response()->stream(null , 200, [

            'Cache-Control' => 'no-cache',

            'Content-Type' => 'text/event-stream',

            'X-Accel-Buffering' => 'no',
<?php             return json_decode($response, true);

        }



        return response()->json(json_decode($response, true))

                    ->withCallback($request->callback);

    }
<?php     protected function unauthenticated($request, AuthenticationException $exception)

    {

        return $this->shouldReturnJson($request, $exception)

                    ? response()->json(['message' => $exception->getMessage()], 401)

                    : redirect()->guest($exception->redirectTo($request) ?? route('login'));

    }
<?php     protected function invalidJson($request, ValidationException $exception)

    {

        return response()->json([

            'message' => $exception->getMessage(),

            'errors' => $exception->errors(),

        ], $exception->status);
<?php         if ($view = $this->getHttpExceptionView($e)) {

            try {

                return response()->view($view, [

                    'errors' => new ViewErrorBag,

                    'exception' => $e,

                ], $e->getStatusCode(), $e->getHeaders());
<?php             }



            if (isset($data['template'])) {

                return response(

                    $data['template'],

                    $data['status'] ?? 503,

                    $this->getHeaders($data)

                );

            }



            throw new HttpException(
<?php     public function toResponse($request)

    {

        return tap(response()->json(

            $this->wrap(

                $this->resource->resolve($request),

                array_merge_recursive(
<?php     public function toResponse($request)

    {

        return tap(response()->json(

            $this->wrap(

                $this->resource->resolve($request),

                $this->resource->with($request),