CouponSettings.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Settings;
  3. use Spatie\LaravelSettings\Settings;
  4. class CouponSettings extends Settings
  5. {
  6. public bool $enabled;
  7. public bool $delete_coupon_on_expires;
  8. public bool $delete_coupon_on_uses_reached;
  9. public ?int $max_uses_per_user;
  10. public static function group(): string
  11. {
  12. return 'coupon';
  13. }
  14. /**
  15. * Summary of validations array
  16. * @return array<string, string>
  17. */
  18. public static function getValidations()
  19. {
  20. return [
  21. 'enabled' => "nullable|boolean",
  22. 'delete_coupon_on_expires' => 'nullable|boolean',
  23. 'delete_coupon_on_uses_reached' => 'nullable|boolean',
  24. 'max_uses_per_user' => 'nullable|integer',
  25. ];
  26. }
  27. /**
  28. * Summary of optionInputData array
  29. * Only used for the settings page
  30. * @return array<array<'type'|'label'|'description'|'options', string|bool|float|int|array<string, string>>>
  31. */
  32. public static function getOptionInputData()
  33. {
  34. return [
  35. "category_icon" => "fas fa-ticket-alt",
  36. 'enabled' => [
  37. 'label' => 'Enable Coupons',
  38. 'type' => 'boolean',
  39. 'description' => 'Enables coupons to be used in the store.'
  40. ],
  41. 'delete_coupon_on_expires' => [
  42. 'label' => 'Auto Delete Expired Coupons',
  43. 'type' => 'boolean',
  44. 'description' => 'Automatically deletes the coupon if it expires.'
  45. ],
  46. 'delete_coupon_on_uses_reached' => [
  47. 'label' => 'Delete Coupon When Max Uses Reached',
  48. 'type' => 'boolean',
  49. 'description' => 'Delete a coupon as soon as its maximum usage is reached.'
  50. ],
  51. 'max_uses_per_user' => [
  52. 'label' => 'Max Uses Per User',
  53. 'type' => 'number',
  54. 'description' => 'Maximum number of uses that a user can make of the same coupon.'
  55. ],
  56. ];
  57. }
  58. }