tags
This commit is contained in:
@ -2,12 +2,14 @@
|
||||
|
||||
namespace app\modules\tag;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use itguild\forms\builders\TextInputBuilder;
|
||||
use kernel\app_modules\tag\models\Tag;
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\helpers\Slug;
|
||||
use kernel\Module;
|
||||
use kernel\modules\menu\service\MenuService;
|
||||
use kernel\modules\option\service\OptionService;
|
||||
use kernel\Request;
|
||||
use kernel\services\MigrationService;
|
||||
|
||||
@ -34,29 +36,50 @@ class TagModule extends Module
|
||||
"url" => "/admin/tag",
|
||||
"slug" => "tag",
|
||||
]);
|
||||
|
||||
$this->menuService->createItem([
|
||||
"label" => "Тэги",
|
||||
"url" => "/admin/settings/tag",
|
||||
"slug" => "tag_settings",
|
||||
"parent_slug" => "settings"
|
||||
]);
|
||||
|
||||
OptionService::createFromParams("entity_tag_list", "{}", "Список тегов");
|
||||
}
|
||||
|
||||
public function deactivate(): void
|
||||
{
|
||||
$this->menuService->removeItemBySlug("tag");
|
||||
OptionService::removeOptionByKey("entity_tag_list");
|
||||
}
|
||||
|
||||
public function formInputs(): void
|
||||
public function formInputs(string $entity, Model $model = null): void
|
||||
{
|
||||
$input = TextInputBuilder::build("tag", ['class' => 'form-control', 'placeholder' => 'Теги']);
|
||||
$tag = Tag::where("entity", $entity)->where("entity_id", $model->id)->first();
|
||||
|
||||
$input = TextInputBuilder::build("tag", [
|
||||
'class' => 'form-control',
|
||||
'placeholder' => 'Теги',
|
||||
'value' => $tag->label ?? ""
|
||||
]);
|
||||
$input->setLabel("Теги");
|
||||
$input->create()->render();
|
||||
}
|
||||
|
||||
public function saveInputs(string $entity, Request $request): void
|
||||
public function saveInputs(string $entity, Model $model, Request $request): void
|
||||
{
|
||||
$model = new Tag();
|
||||
$model->entity = $entity;
|
||||
Debug::dd($request->post());
|
||||
$model->entity_id = 1;
|
||||
$model->label = $request->post('tag');
|
||||
$model->status = Tag::ACTIVE_STATUS;
|
||||
$model->slug = Slug::createSlug($request->post('tag'), $model);
|
||||
$model->save();
|
||||
$tag = new Tag();
|
||||
$tag->entity = $entity;
|
||||
$tag->entity_id = $model->id;
|
||||
$tag->label = $request->post('tag');
|
||||
$tag->status = Tag::ACTIVE_STATUS;
|
||||
$tag->slug = Slug::createSlug($request->post('tag'), $model);
|
||||
$tag->save();
|
||||
}
|
||||
|
||||
public function getInputs(string $entity, Model $model)
|
||||
{
|
||||
|
||||
Debug::dd($tag);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user