2023-02-02 15:45:17 +00:00
|
|
|
<?php
|
|
|
|
|
2023-02-06 20:16:54 +00:00
|
|
|
namespace App\Settings;
|
2023-02-02 15:45:17 +00:00
|
|
|
|
|
|
|
use Spatie\LaravelSettings\Settings;
|
|
|
|
|
|
|
|
class ReferralSettings extends Settings
|
|
|
|
{
|
2023-04-02 17:57:28 +00:00
|
|
|
public bool $always_give_commission;
|
|
|
|
public bool $enabled;
|
2023-03-30 14:21:31 +00:00
|
|
|
public ?float $reward;
|
2023-02-02 15:45:17 +00:00
|
|
|
public string $mode;
|
2023-03-30 14:21:31 +00:00
|
|
|
public ?int $percentage;
|
2023-02-02 15:45:17 +00:00
|
|
|
|
|
|
|
public static function group(): string
|
|
|
|
{
|
|
|
|
return 'referral';
|
|
|
|
}
|
2023-02-09 21:34:34 +00:00
|
|
|
|
2023-02-09 23:31:27 +00:00
|
|
|
/**
|
|
|
|
* Summary of validations array
|
|
|
|
* @return array<string, string>
|
|
|
|
*/
|
|
|
|
public static function getValidations()
|
|
|
|
{
|
|
|
|
return [
|
2023-05-08 12:42:46 +00:00
|
|
|
'always_give_commission' => 'nullable|string',
|
|
|
|
'enabled' => 'nullable|string',
|
2023-02-09 23:31:27 +00:00
|
|
|
'reward' => 'nullable|numeric',
|
2023-06-04 14:10:09 +00:00
|
|
|
'mode' => 'required|in:commission,sign-up,both',
|
2023-02-09 23:31:27 +00:00
|
|
|
'percentage' => 'nullable|numeric',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2023-02-09 21:34:34 +00:00
|
|
|
/**
|
|
|
|
* Summary of optionTypes
|
|
|
|
* Only used for the settings page
|
|
|
|
* @return array<array<'type'|'label'|'description'|'options', string|bool|float|int|array<string, string>>>
|
|
|
|
*/
|
|
|
|
public static function getOptionInputData()
|
|
|
|
{
|
|
|
|
return [
|
2023-02-20 12:44:06 +00:00
|
|
|
'category_icon' => 'fas fa-user-friends',
|
2023-02-09 21:34:34 +00:00
|
|
|
'always_give_commission' => [
|
|
|
|
'label' => 'Always Give Commission',
|
|
|
|
'type' => 'boolean',
|
2023-05-07 17:05:50 +00:00
|
|
|
'description' => 'Always give commission to the referrer or only on the first Purchase.',
|
2023-02-09 21:34:34 +00:00
|
|
|
],
|
|
|
|
'enabled' => [
|
|
|
|
'label' => 'Enabled',
|
|
|
|
'type' => 'boolean',
|
|
|
|
'description' => 'Enable referral system.',
|
|
|
|
],
|
|
|
|
'reward' => [
|
|
|
|
'label' => 'Reward',
|
|
|
|
'type' => 'number',
|
|
|
|
'description' => 'Reward for the referrer.',
|
|
|
|
],
|
|
|
|
'mode' => [
|
|
|
|
'label' => 'Mode',
|
|
|
|
'type' => 'select',
|
|
|
|
'description' => 'Referral mode.',
|
|
|
|
'options' => [
|
2023-03-30 14:21:31 +00:00
|
|
|
'commission' => 'Commission',
|
2023-02-09 21:34:34 +00:00
|
|
|
'sign-up' => 'Sign-Up',
|
|
|
|
'both' => 'Both',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'percentage' => [
|
|
|
|
'label' => 'Percentage',
|
|
|
|
'type' => 'number',
|
|
|
|
'description' => 'If a referred user buys credits, the referral-user will get x% of the Credits the referred user bought.',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|