first prod

This commit is contained in:
2025-07-20 15:02:06 +03:00
parent 273ac72207
commit d3af15c5ac
106 changed files with 56912 additions and 63 deletions

View File

@@ -3,6 +3,7 @@
namespace kernel\modules\option\service;
use kernel\FormModel;
use kernel\helpers\Debug;
use kernel\modules\option\models\Option;
class OptionService
@@ -49,6 +50,26 @@ class OptionService
return false;
}
public static function createOrUpdate(string $key, string $value, string $label = ''): false|Option
{
/** @var Option $option */
$option = self::getItemObject($key);
if (!$option) {
$option = new Option();
$option->key = $key;
}
$option->value = $value;
if (!empty($label)){
$option->label = $label;
}
if ($option->save()) {
return $option;
}
return false;
}
/**
* @param $key
* @return false|array|string
@@ -63,6 +84,20 @@ class OptionService
return false;
}
/**
* @param $key
* @return false|array|string|Option
*/
public static function getItemObject($key): false|array|string|Option
{
$item = Option::where("key", $key)->first();
if ($item){
return $item;
}
return false;
}
public static function removeOptionByKey(string $key): bool
{
$option = Option::where("key", $key)->first();