ctrlpanel/app/Settings/ReferralSettings.php

93 lines
2.7 KiB
PHP

<?php
namespace App\Settings;
use Spatie\LaravelSettings\Settings;
class ReferralSettings extends Settings
{
public string $allowed;
public bool $always_give_commission = false;
public bool $enabled = false;
public ?float $reward;
public string $mode;
public ?int $percentage;
public static function group(): string
{
return 'referral';
}
/**
* Summary of validations array
* @return array<string, string>
*/
public static function getValidations()
{
return [
'allowed' => 'required|in:everyone,clients',
'always_give_commission' => 'nullable|boolean',
'enabled' => 'nullable|boolean',
'reward' => 'nullable|numeric',
'mode' => 'required|in:commission,percentage,both',
'percentage' => 'nullable|numeric',
];
}
/**
* 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 [
'category_icon' => 'fas fa-user-friends',
'allowed' => [
'label' => 'Allowed',
'type' => 'select',
'description' => 'Who is allowed to see their referral-URL',
'options' => [
'everyone' => 'Everyone',
'clients' => 'Clients',
],
],
'always_give_commission' => [
'label' => 'Always Give Commission',
'type' => 'boolean',
'description' => 'Always give commission to the referrer.',
],
'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' => [
'commission' => 'Commission',
'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.',
],
];
}
}