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.

77 lines
1.8 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. [
  12. 'name' => 'Replace with',
  13. 'type' => 'select',
  14. 'values' => [
  15. '#', '*', 'x'
  16. ]
  17. ]
  18. ]
  19. ],
  20. 'email' => [
  21. 'display_name' => 'Email',
  22. 'options' => [
  23. [
  24. 'name' => 'Replace with',
  25. 'type' => 'select',
  26. 'values' => [
  27. '#', '*', 'x'
  28. ]
  29. ],
  30. [
  31. 'name' => 'Include domain',
  32. 'type' => 'switch'
  33. ]
  34. ]
  35. ]
  36. ];
  37. /**
  38. * Create a new filter
  39. *
  40. * @return JsonResponse
  41. *
  42. * @throws BindingResolutionException
  43. */
  44. public function create(): JsonResponse
  45. {
  46. return response()->json([
  47. 'result' => 'success'
  48. ]);
  49. }
  50. /**
  51. * Get one or all the filters we have
  52. *
  53. * @param string|null $id The ID of the filter. Null if we want all of them
  54. *
  55. * @return JsonResponse
  56. *
  57. * @throws BindingResolutionException
  58. */
  59. public function get(string $id = null): JsonResponse
  60. {
  61. if ($id === null) {
  62. return response()->json(static::$filters);
  63. }
  64. if (!empty(static::$filters[$id])) {
  65. return response()-> json(static::$filters[$id]);
  66. }
  67. abort(404);
  68. }
  69. }