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.

68 lines
1.5 KiB

  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Contracts\Container\BindingResolutionException;
  4. use Illuminate\Http\JsonResponse;
  5. class FilterController extends Controller
  6. {
  7. public static array $filters = [
  8. 'phone_number' => [
  9. 'display_name' => 'Phone number',
  10. 'options' => [
  11. 'replace_with' => [
  12. '#', '*', 'x',
  13. ]
  14. ]
  15. ],
  16. 'email' => [
  17. 'display_name' => 'Email',
  18. 'options' => [
  19. 'replace_with' => [
  20. '#', '*', 'x',
  21. ],
  22. 'include_domain' => [
  23. true, false
  24. ]
  25. ]
  26. ]
  27. ];
  28. /**
  29. * Create a new filter
  30. *
  31. * @return JsonResponse
  32. *
  33. * @throws BindingResolutionException
  34. */
  35. public function create(): JsonResponse
  36. {
  37. return response()->json([
  38. 'result' => 'success'
  39. ]);
  40. }
  41. /**
  42. * Get one or all the filters we have
  43. *
  44. * @param string|null $id The ID of the filter. Null if we want all of them
  45. *
  46. * @return JsonResponse
  47. *
  48. * @throws BindingResolutionException
  49. */
  50. public function get(string $id = null): JsonResponse
  51. {
  52. if ($id === null) {
  53. return response()->json(static::$filters);
  54. }
  55. if (!empty(static::$filters[$id])) {
  56. return response()-> json(static::$filters[$id]);
  57. }
  58. abort(404);
  59. }
  60. }