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             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),
<?php         $this->handler->renderable(function (CustomException $e, $request) {

            $this->assertSame($this->request, $request);



            return response()->json(['response' => 'My custom exception response']);

        });



        $response = $this->handler->render($this->request, new CustomException)->getContent();
<?php {

    public function toResponse($request)

    {

        return response()->json(['response' => 'My responsable exception response']);

    }

}
<?php {

    public function render($request)

    {

        return response()->json(['response' => 'My renderable exception response']);

    }

}
<?php {

    public function __invoke(CustomException $e, $request)

    {

        return response()->json(['response' => 'The CustomRenderer response']);

    }

}
<?php         $this->router = $this->app->make(Registrar::class);



        $this->router->get('/login', function () {

            return response('Login Form');

        })->middleware(RedirectIfAuthenticated::class);



        UserFactory::new()->create();
<?php         $user = AuthenticationTestUser::first();

        $this->router->get('/login', function () {

            return response('Login Form');

        })->middleware(RedirectIfAuthenticated::class);



        UserFactory::new()->create();
<?php     public function testWhenDashboardNamedRouteIsAvailable()

    {

        $this->router->get('/named-dashboard', function () {

            return response('Named Dashboard');

        })->name('dashboard');



        $response = $this->actingAs($this->user)->get('/login');
<?php     public function testWhenHomeNamedRouteIsAvailable()

    {

        $this->router->get('/named-home', function () {

            return response('Named Home');

        })->name('home');



        $response = $this->actingAs($this->user)->get('/login');