From 99ef6e671eb41dcdd11eafcb96b0aa39ae782768 Mon Sep 17 00:00:00 2001 From: mychidarko Date: Tue, 28 Jan 2025 20:59:59 +0000 Subject: [PATCH] feat: add router::view to return views from routes --- src/Router.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Router.php b/src/Router.php index 7845da6..92fce43 100644 --- a/src/Router.php +++ b/src/Router.php @@ -325,6 +325,19 @@ public static function redirect( }); } + /** + * Add a route that renders a view + * + * @param string $pattern The route pattern/path to match + * @param string $view The view to render + */ + public static function view(string $pattern, string $view) + { + static::get($pattern, function () use ($view) { + return response()->view($view); + }); + } + /** * Create a resource route for using controllers. *