-
-
Notifications
You must be signed in to change notification settings - Fork 664
Expand file tree
/
Copy pathAsyncController.php
More file actions
91 lines (76 loc) · 2.17 KB
/
Copy pathAsyncController.php
File metadata and controls
91 lines (76 loc) · 2.17 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
declare(strict_types=1);
namespace Orchid\Platform\Http\Controllers;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Crypt;
use Orchid\Screen\Layouts\Listener;
use Orchid\Screen\Screen;
class AsyncController extends Controller
{
/**
* @throws \Throwable
*
* @return mixed
*/
public function load(Request $request)
{
$request->validate([
'_call' => 'required|string',
'_screen' => 'required|string',
'_template' => 'required|string',
]);
$screen = Crypt::decryptString(
$request->input('_screen')
);
/** @var Screen $screen */
$screen = app($screen);
return $screen->asyncBuild(
$request->input('_call'),
$request->input('_template')
);
}
/**
* @param Request $request
* @param string $screen
* @param string $layout
*
* @throws BindingResolutionException
* @throws \ReflectionException
*
* @return mixed
*/
public function listener(Request $request, string $screen, string $layout)
{
$screen = Crypt::decryptString($screen);
$layout = Crypt::decryptString($layout);
/** @var Screen $screen */
$screen = app($screen);
/** @var Listener $layout */
$layout = app($layout);
return $screen->asyncPartialLayout($layout, $request);
}
/**
* @throws BindingResolutionException
* @throws \ReflectionException
*/
public function rowDetail(Request $request)
{
$request->validate([
'_call' => 'required|string',
'_layout' => 'required|string',
'_screen' => 'required|string',
'_target' => 'required|string',
]);
$screen = Crypt::decryptString(
$request->input('_screen')
);
/** @var Screen $screen */
$screen = app($screen);
return $screen->asyncRowDetail(
$request->input('_call'),
$request->input('_layout'),
$request->input('_target')
);
}
}