refactor(Core): optimize admin panel and refactor

This commit is contained in:
2026-05-07 00:15:32 +03:30
parent dec4e67b9e
commit 7cc14b7439
25 changed files with 1162 additions and 282 deletions

View File

@@ -18,6 +18,10 @@ class Rule {
public $enabled;
public $created_at;
public $updated_at;
public $condition_type;
public $condition_value;
public $action_type;
public $action_value;
/**
* Constructor
@@ -36,6 +40,7 @@ class Rule {
$this->enabled = isset($data['enabled']) ? (int) $data['enabled'] : 1;
$this->created_at = $data['created_at'] ?? null;
$this->updated_at = $data['updated_at'] ?? null;
$this->syncLegacyFields();
}
private function parseJsonField($value) {
@@ -59,6 +64,16 @@ class Rule {
return array_filter(array_map('trim', explode(',', $value)));
}
public function syncLegacyFields() {
$condition = $this->conditions[0] ?? [];
$action = $this->actions[0] ?? [];
$this->condition_type = $condition['type'] ?? 'user_type';
$this->condition_value = $condition['value'] ?? 'new';
$this->action_type = $action['type'] ?? 'discount_percent';
$this->action_value = $action['value'] ?? 0;
}
/**
* Convert to array
*/