ReferralSettings.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace App\Settings;
  3. use Spatie\LaravelSettings\Settings;
  4. class ReferralSettings extends Settings
  5. {
  6. public bool $always_give_commission;
  7. public bool $enabled;
  8. public ?float $reward;
  9. public string $mode;
  10. public ?int $percentage;
  11. public static function group(): string
  12. {
  13. return 'referral';
  14. }
  15. /**
  16. * Summary of validations array
  17. * @return array<string, string>
  18. */
  19. public static function getValidations()
  20. {
  21. return [
  22. 'always_give_commission' => 'nullable|string',
  23. 'enabled' => 'nullable|string',
  24. 'reward' => 'nullable|numeric',
  25. 'mode' => 'required|in:commission,sign-up,both',
  26. 'percentage' => 'nullable|numeric',
  27. ];
  28. }
  29. /**
  30. * Summary of optionTypes
  31. * Only used for the settings page
  32. * @return array<array<'type'|'label'|'description'|'options', string|bool|float|int|array<string, string>>>
  33. */
  34. public static function getOptionInputData()
  35. {
  36. return [
  37. 'category_icon' => 'fas fa-user-friends',
  38. 'always_give_commission' => [
  39. 'label' => 'Always Give Commission',
  40. 'type' => 'boolean',
  41. 'description' => 'Always give commission to the referrer or only on the first Purchase.',
  42. ],
  43. 'enabled' => [
  44. 'label' => 'Enabled',
  45. 'type' => 'boolean',
  46. 'description' => 'Enable referral system.',
  47. ],
  48. 'reward' => [
  49. 'label' => 'Reward',
  50. 'type' => 'number',
  51. 'description' => 'Reward for the referrer.',
  52. ],
  53. 'mode' => [
  54. 'label' => 'Mode',
  55. 'type' => 'select',
  56. 'description' => 'Referral mode.',
  57. 'options' => [
  58. 'commission' => 'Commission',
  59. 'sign-up' => 'Sign-Up',
  60. 'both' => 'Both',
  61. ],
  62. ],
  63. 'percentage' => [
  64. 'label' => 'Percentage',
  65. 'type' => 'number',
  66. 'description' => 'If a referred user buys credits, the referral-user will get x% of the Credits the referred user bought.',
  67. ],
  68. ];
  69. }
  70. }