2023-05-17 16:17:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Settings;
|
|
|
|
|
|
|
|
use Spatie\LaravelSettings\Settings;
|
|
|
|
|
|
|
|
class CouponSettings extends Settings
|
|
|
|
{
|
2023-05-19 15:00:30 +00:00
|
|
|
public bool $enabled;
|
|
|
|
public bool $delete_coupon_on_expires;
|
|
|
|
public bool $delete_coupon_on_uses_reached;
|
|
|
|
public ?int $max_uses_per_user;
|
2023-05-17 16:17:51 +00:00
|
|
|
|
|
|
|
public static function group(): string
|
|
|
|
{
|
|
|
|
return 'coupon';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Summary of validations array
|
|
|
|
* @return array<string, string>
|
|
|
|
*/
|
|
|
|
public static function getValidations()
|
|
|
|
{
|
|
|
|
return [
|
2023-05-19 15:00:30 +00:00
|
|
|
'enabled' => "nullable|boolean",
|
|
|
|
'delete_coupon_on_expires' => 'nullable|boolean',
|
|
|
|
'delete_coupon_on_uses_reached' => 'nullable|boolean',
|
|
|
|
'max_uses_per_user' => 'nullable|integer',
|
2023-05-17 16:17:51 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Summary of optionInputData array
|
|
|
|
* 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-ticket-alt",
|
2023-05-19 15:00:30 +00:00
|
|
|
'enabled' => [
|
|
|
|
'label' => 'Enable Coupons',
|
|
|
|
'type' => 'boolean',
|
|
|
|
'description' => 'Enables coupons to be used in the store.'
|
2023-05-18 19:51:10 +00:00
|
|
|
],
|
|
|
|
'delete_coupon_on_expires' => [
|
2023-05-19 14:01:10 +00:00
|
|
|
'label' => 'Auto Delete Expired Coupons',
|
2023-05-18 19:51:10 +00:00
|
|
|
'type' => 'boolean',
|
|
|
|
'description' => 'Automatically deletes the coupon if it expires.'
|
|
|
|
],
|
|
|
|
'delete_coupon_on_uses_reached' => [
|
|
|
|
'label' => 'Delete Coupon When Max Uses Reached',
|
|
|
|
'type' => 'boolean',
|
|
|
|
'description' => 'Delete a coupon as soon as its maximum usage is reached.'
|
2023-05-19 15:00:30 +00:00
|
|
|
],
|
|
|
|
'max_uses_per_user' => [
|
|
|
|
'label' => 'Max Uses Per User',
|
|
|
|
'type' => 'number',
|
|
|
|
'description' => 'Maximum number of uses that a user can make of the same coupon.'
|
|
|
|
],
|
2023-05-17 16:17:51 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|