2
2
3
3
namespace Leeovery \LaravelPlaywright \Http \Controllers ;
4
4
5
+ use Exception ;
5
6
use Illuminate \Database \Eloquent \Factories \Factory ;
6
7
use Illuminate \Http \Request ;
7
8
use Illuminate \Routing \Route as RoutingRoute ;
@@ -14,17 +15,36 @@ class LaravelPlaywrightController
14
15
{
15
16
public function migrate (Request $ request )
16
17
{
17
- Artisan::call (command: 'migrate:fresh ' .($ request ->boolean ('seed ' ) ? ' --seed ' : '' ));
18
+ try {
19
+ Artisan::call ('migrate:fresh --schema-path=false ' .($ request ->boolean ('seed ' ) ? ' --seed ' : '' ));
20
+ } catch (Exception $ exception ) {
21
+ return response ()->json ($ exception ->getMessage (), 500 );
22
+ }
23
+
24
+ return response ()->json (Artisan::output (), 202 );
18
25
}
19
26
20
27
public function setupEnv ()
21
28
{
22
- return Artisan::call (command: 'playwright:env-setup ' );
29
+ try {
30
+ Artisan::call ('playwright:env-setup ' );
31
+ sleep (2 );
32
+ } catch (Exception $ exception ) {
33
+ return response ()->json ($ exception ->getMessage (), 500 );
34
+ }
35
+
36
+ return response ()->json (null , 202 );
23
37
}
24
38
25
39
public function tearDownEnv ()
26
40
{
27
- return Artisan::call (command: 'playwright:env-teardown ' );
41
+ try {
42
+ Artisan::call ('playwright:env-teardown ' );
43
+ } catch (Exception $ exception ) {
44
+ return response ()->json ($ exception ->getMessage (), 500 );
45
+ }
46
+
47
+ return response ()->json (null , 202 );
28
48
}
29
49
30
50
public function routes (Request $ request )
@@ -130,10 +150,18 @@ public function logout()
130
150
131
151
public function artisan (Request $ request )
132
152
{
133
- Artisan::call (
134
- command: $ request ->input ('command ' ),
135
- parameters: $ request ->input ('parameters ' , [])
136
- );
153
+ $ request ->validate (['command ' => 'required ' ]);
154
+
155
+ try {
156
+ Artisan::call (
157
+ command: $ request ->input ('command ' ),
158
+ parameters: $ request ->input ('parameters ' , [])
159
+ );
160
+ } catch (Exception $ exception ) {
161
+ abort ($ exception ->getCode (), $ exception ->getMessage ());
162
+ }
163
+
164
+ return response ()->json (Artisan::output (), 202 );
137
165
}
138
166
139
167
public function csrf ()
0 commit comments