tag settings
This commit is contained in:
parent
6d9d19ce36
commit
bba35c7b14
@ -71,6 +71,7 @@ class TagModule extends Module
|
|||||||
{
|
{
|
||||||
$tag = new Tag();
|
$tag = new Tag();
|
||||||
$tag->label = $request->post('tag');
|
$tag->label = $request->post('tag');
|
||||||
|
$tag->entity = $entity;
|
||||||
$tag->status = Tag::ACTIVE_STATUS;
|
$tag->status = Tag::ACTIVE_STATUS;
|
||||||
$tag->slug = Slug::createSlug($request->post('tag'), $model);
|
$tag->slug = Slug::createSlug($request->post('tag'), $model);
|
||||||
$tag->save();
|
$tag->save();
|
||||||
|
@ -18,13 +18,14 @@ class EntityRelation
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getEntityList(): array
|
public static function getEntityList(): array
|
||||||
{
|
{
|
||||||
$list = [];
|
$list = [];
|
||||||
$activeModules = $this->moduleService->getActiveModules();
|
$moduleService = new ModuleService();
|
||||||
|
$activeModules = $moduleService->getActiveModules();
|
||||||
foreach ($activeModules as $module) {
|
foreach ($activeModules as $module) {
|
||||||
if (isset($module['type']) and $module['type'] === "entity") {
|
if (isset($module['type']) and $module['type'] === "entity") {
|
||||||
$list[] = $module['slug'];
|
$list[$module['slug']] = $module['name'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ class TagController extends AdminController
|
|||||||
|
|
||||||
public function actionSettings(): void
|
public function actionSettings(): void
|
||||||
{
|
{
|
||||||
echo "tag settings";
|
$this->cgView->render('form.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -14,6 +14,7 @@ return new class extends Migration
|
|||||||
\kernel\App::$db->schema->create('tag', function (Blueprint $table) {
|
\kernel\App::$db->schema->create('tag', function (Blueprint $table) {
|
||||||
$table->increments('id');
|
$table->increments('id');
|
||||||
$table->string('label', 255)->nullable(false);
|
$table->string('label', 255)->nullable(false);
|
||||||
|
$table->string('entity', 255)->nullable(false);
|
||||||
$table->string('slug', 255)->unique();
|
$table->string('slug', 255)->unique();
|
||||||
$table->integer('status')->default(1);
|
$table->integer('status')->default(1);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
@ -25,6 +25,7 @@ class Tag extends Model
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'label' => 'Заголовок',
|
'label' => 'Заголовок',
|
||||||
|
'entity' => 'Сущность',
|
||||||
'slug' => 'Slug',
|
'slug' => 'Slug',
|
||||||
'status' => 'Статус',
|
'status' => 'Статус',
|
||||||
];
|
];
|
||||||
|
@ -11,6 +11,7 @@ class CreateTagForm extends FormModel
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'label' => 'required|min-str-len:5|max-str-len:30',
|
'label' => 'required|min-str-len:5|max-str-len:30',
|
||||||
|
'entity' => 'required',
|
||||||
'slug' => '',
|
'slug' => '',
|
||||||
'status' => ''
|
'status' => ''
|
||||||
];
|
];
|
||||||
|
@ -4,15 +4,17 @@ namespace kernel\app_modules\tag\services;
|
|||||||
|
|
||||||
use kernel\app_modules\tag\models\Tag;
|
use kernel\app_modules\tag\models\Tag;
|
||||||
use kernel\FormModel;
|
use kernel\FormModel;
|
||||||
|
use kernel\helpers\Debug;
|
||||||
use kernel\helpers\Slug;
|
use kernel\helpers\Slug;
|
||||||
|
use kernel\services\ModuleService;
|
||||||
|
|
||||||
class TagService
|
class TagService
|
||||||
{
|
{
|
||||||
|
|
||||||
public function create(FormModel $form_model): false|Tag
|
public function create(FormModel $form_model): false|Tag
|
||||||
{
|
{
|
||||||
$model = new Tag();
|
$model = new Tag();
|
||||||
$model->label = $form_model->getItem('label');
|
$model->label = $form_model->getItem('label');
|
||||||
|
$model->entity = $form_model->getItem('entity');
|
||||||
$model->status = $form_model->getItem('status');
|
$model->status = $form_model->getItem('status');
|
||||||
$model->slug = Slug::createSlug($form_model->getItem('label'), Tag::class);
|
$model->slug = Slug::createSlug($form_model->getItem('label'), Tag::class);
|
||||||
if ($model->save()){
|
if ($model->save()){
|
||||||
@ -28,6 +30,7 @@ class TagService
|
|||||||
$tag->slug = Slug::createSlug($form_model->getItem('label'), Tag::class);
|
$tag->slug = Slug::createSlug($form_model->getItem('label'), Tag::class);
|
||||||
}
|
}
|
||||||
$tag->label = $form_model->getItem('label');
|
$tag->label = $form_model->getItem('label');
|
||||||
|
$tag->entity = $form_model->getItem('entity');
|
||||||
$tag->status = $form_model->getItem('status');
|
$tag->status = $form_model->getItem('status');
|
||||||
|
|
||||||
if ($tag->save()){
|
if ($tag->save()){
|
||||||
|
@ -16,6 +16,14 @@ $form->field(class: \itguild\forms\inputs\TextInput::class, name: "label", param
|
|||||||
->setLabel("Заголовок")
|
->setLabel("Заголовок")
|
||||||
->render();
|
->render();
|
||||||
|
|
||||||
|
$form->field(class: \itguild\forms\inputs\Select::class, name: "entity", params: [
|
||||||
|
'class' => "form-control",
|
||||||
|
'value' => $model->entity ?? ''
|
||||||
|
])
|
||||||
|
->setLabel("Сущность")
|
||||||
|
->setOptions(\kernel\EntityRelation::getEntityList())
|
||||||
|
->render();
|
||||||
|
|
||||||
$form->field(\itguild\forms\inputs\Select::class, 'status', [
|
$form->field(\itguild\forms\inputs\Select::class, 'status', [
|
||||||
'class' => "form-control",
|
'class' => "form-control",
|
||||||
'value' => $model->status ?? ''
|
'value' => $model->status ?? ''
|
||||||
|
Loading…
Reference in New Issue
Block a user