tag settings

This commit is contained in:
2024-12-02 14:15:01 +03:00
parent b981ff0c44
commit 567ab8544d
4 changed files with 38 additions and 20 deletions

View File

@ -111,32 +111,32 @@ class TagController extends AdminController
$request = new Request();
$entities = $request->post('entity');
$entityRelationsModel = Option::where("key", "entity_relations")->first();
$entityRelations = json_decode($entityRelationsModel->value, true);
Debug::prn($entities);
Debug::prn($entityRelations);
$entityRelations = EntityRelation::getEntitiesRelations();
if (isset($entities)) {
foreach ($entities as $entity) {
if (!isset($entityRelations[$entity])) {
EntityRelation::addEntityRelation($entity, 'tag');
}
}
foreach ($entityRelations as $entity => $property) {
if (in_array($entity, $entities)) {
if (!in_array('tag', $property)) {
EntityRelation::addEntityRelation($entity, 'tag');
}
} else {
EntityRelation::removePropertyFromEntityRelations($entity, array_search('tag', $property));
if (in_array('tag', $property)) {
EntityRelation::removePropertyFromEntityRelations($entity, 'tag');
}
}
}
} else {
foreach ($entityRelations as $entity => $property) {
EntityRelation::removeEntityRelation($entity);
EntityRelation::removePropertyFromEntityRelations($entity, 'tag');
}
}
// $this->redirect("/admin/settings/tag");
$this->redirect("/admin/settings/tag", 302);
}
}

View File

@ -1,14 +1,13 @@
<?php
use itguild\forms\builders\SelectBuilder;
use kernel\EntityRelation;
$form = new \itguild\forms\ActiveForm();
$form->beginForm("/admin/settings/tag/update");
//\kernel\helpers\Debug::dd($value);
$form->field(\itguild\forms\inputs\Select::class, "entity[]", [
'class' => "form-control",
'value' => $model->entity ?? '',
'value' => \kernel\EntityRelation::getEntityByProperty('tag') ?? '',
'multiple' => "multiple",
])