-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathhelpers.php
More file actions
41 lines (35 loc) · 908 Bytes
/
helpers.php
File metadata and controls
41 lines (35 loc) · 908 Bytes
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
37
38
39
40
41
<?php
use Illuminate\Contracts\Support\Arrayable;
use Inertia\Inertia;
use Inertia\Response;
use Inertia\ResponseFactory;
if (! function_exists('inertia')) {
/**
* Inertia helper.
*
* @param null|string $component
* @param array|Arrayable $props
* @return ($component is null ? ResponseFactory : Response)
*/
function inertia($component = null, $props = [])
{
$instance = 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::getFacadeRoot();
return $instance->location($url);
}
}