Skip to content

Commit 2e0cab6

Browse files
committed
feat: add inertia route
1 parent d09dde2 commit 2e0cab6

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/Router.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,26 @@ public static function redirect(
330330
*
331331
* @param string $pattern The route pattern/path to match
332332
* @param string $view The view to render
333+
* @param array $data The data to pass to the view
333334
*/
334-
public static function view(string $pattern, string $view)
335+
public static function view(string $pattern, string $view, $data = [])
335336
{
336-
static::get($pattern, function () use ($view) {
337-
return response()->view($view);
337+
static::get($pattern, function () use ($view, $data) {
338+
return response()->view($view, $data);
339+
});
340+
}
341+
342+
/**
343+
* Add a route that renders an inertia view
344+
*
345+
* @param string $pattern The route pattern/path to match
346+
* @param string $view The view to render
347+
* @param array $data The data to pass to the view
348+
*/
349+
public static function inertia(string $pattern, string $view, $data = [])
350+
{
351+
static::get($pattern, function () use ($view, $data) {
352+
return inertia($view, $data);
338353
});
339354
}
340355

0 commit comments

Comments
 (0)