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.

37 lines
867 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. 'expression' => 'required',
  15. ]);
  16. try {
  17. $factory = new RegexFactory(request()->get('name'), request()->get('expression'));
  18. $searcher = $factory->create();
  19. return response()->json([
  20. 'status' => 'success',
  21. 'searcher' => $searcher,
  22. ], 200);
  23. } catch (\Exception $exception) {
  24. return response()->json([
  25. 'status' => 'fail',
  26. 'message' => $exception->getMessage(),
  27. ], 400);
  28. }
  29. }
  30. }