Repo for the search and displace core module including the interface to select files and search and displace operations to run on them. https://searchanddisplace.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
985 B

  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\SearchDisplace\Regex\RegexFactory;
  4. class RegexController extends Controller
  5. {
  6. public function create()
  7. {
  8. return view('pages.regex.create');
  9. }
  10. public function store()
  11. {
  12. request()->validate([
  13. 'name' => 'required',
  14. 'tag' => 'nullable',
  15. 'expression' => 'required',
  16. ]);
  17. try {
  18. $factory = new RegexFactory(
  19. request()->get('name'),
  20. request()->get('expression'),
  21. request()->get('tag')
  22. );
  23. $searcher = $factory->create();
  24. return response()->json([
  25. 'status' => 'success',
  26. 'searcher' => $searcher,
  27. ], 200);
  28. } catch (\Exception $exception) {
  29. return response()->json([
  30. 'status' => 'fail',
  31. 'message' => $exception->getMessage(),
  32. ], 400);
  33. }
  34. }
  35. }