forked from inertiajs/inertia-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.php
36 lines (31 loc) · 833 Bytes
/
helpers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
if (! function_exists('inertia')) {
/**
* Inertia helper.
*
* @param null|string $component
* @param array|\Illuminate\Contracts\Support\Arrayable $props
* @return \Inertia\ResponseFactory|\Inertia\Response
*/
function inertia($component = null, $props = [])
{
$instance = \Inertia\Inertia::getFacadeRoot();
if ($component) {
return $instance->render($component, $props);
}
return $instance;
}
}
if (! function_exists('inertia_location')) {
/**
* Inertia location helper.
*
* @param string url
* @return \Symfony\Component\HttpFoundation\Response
*/
function inertia_location($url)
{
$instance = \Inertia\Inertia::getFacadeRoot();
return $instance->location($url);
}
}