52 lines
1.6 KiB
PHP
52 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace app\modules\module_shop\services;
|
|
|
|
use app\modules\module_shop\models\ModuleShop;
|
|
use kernel\FormModel;
|
|
use kernel\helpers\Debug;
|
|
use kernel\helpers\Files;
|
|
use kernel\helpers\Manifest;
|
|
use kernel\helpers\Slug;
|
|
use kernel\services\ModuleService;
|
|
|
|
class ModuleShopService extends ModuleService
|
|
{
|
|
public function create(FormModel $form_model): false|ModuleShop
|
|
{
|
|
$model = new ModuleShop();
|
|
$model->name = $form_model->getItem("name");
|
|
$model->version = $form_model->getItem("version");
|
|
$model->description = $form_model->getItem("description");
|
|
$model->author = $form_model->getItem("author");
|
|
$model->status = $form_model->getItem("status");
|
|
$model->path_to_archive = $form_model->getItem("path_to_archive");
|
|
$model->dependence = $form_model->getItem("dependence");
|
|
$model->slug = $form_model->getItem("slug");
|
|
|
|
if ($model->save()) {
|
|
return $model;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public function update(FormModel $form_model, ModuleShop $model): false|ModuleShop
|
|
{
|
|
$model->name = $form_model->getItem("name");
|
|
$model->version = $form_model->getItem("version");
|
|
$model->description = $form_model->getItem("description");
|
|
$model->author = $form_model->getItem("author");
|
|
$model->status = $form_model->getItem("status");
|
|
$model->path_to_archive = $form_model->getItem("path_to_archive");
|
|
$model->dependence = $form_model->getItem("dependence");
|
|
$model->slug = $form_model->getItem("slug");
|
|
|
|
if ($model->save()) {
|
|
return $model;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
} |