crud tag entity, some fix tag
This commit is contained in:
@ -5,6 +5,7 @@ namespace app\modules\tag;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use itguild\forms\builders\TextInputBuilder;
|
||||
use kernel\app_modules\tag\models\Tag;
|
||||
use kernel\app_modules\tag\models\TagEntity;
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\helpers\Slug;
|
||||
use kernel\Module;
|
||||
@ -30,7 +31,7 @@ class TagModule extends Module
|
||||
public function init(): void
|
||||
{
|
||||
$this->migrationService->runAtPath("{KERNEL_APP_MODULES}/tag/migrations/tag");
|
||||
// $this->migrationService->runAtPath("{KERNEL_APP_MODULES}/tag/migrations/tag_entity");
|
||||
$this->migrationService->runAtPath("{KERNEL_APP_MODULES}/tag/migrations/tag_entity");
|
||||
|
||||
$this->menuService->createItem([
|
||||
"label" => "Тэги",
|
||||
@ -51,17 +52,16 @@ class TagModule extends Module
|
||||
public function deactivate(): void
|
||||
{
|
||||
$this->menuService->removeItemBySlug("tag");
|
||||
$this->menuService->removeItemBySlug("tag_settings");
|
||||
OptionService::removeOptionByKey("entity_tag_list");
|
||||
}
|
||||
|
||||
public function formInputs(string $entity, Model $model = null): void
|
||||
{
|
||||
$tag = Tag::where("entity", $entity)->where("entity_id", $model->id)->first();
|
||||
|
||||
$input = TextInputBuilder::build("tag", [
|
||||
'class' => 'form-control',
|
||||
'placeholder' => 'Теги',
|
||||
'value' => $tag->label ?? ""
|
||||
'value' => Tag::find($model->id)->label ?? ""
|
||||
]);
|
||||
$input->setLabel("Теги");
|
||||
$input->create()->render();
|
||||
@ -70,12 +70,16 @@ class TagModule extends Module
|
||||
public function saveInputs(string $entity, Model $model, Request $request): void
|
||||
{
|
||||
$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();
|
||||
|
||||
$tagEntity = new TagEntity();
|
||||
$tagEntity->entity = $entity;
|
||||
$tagEntity->entity_id = $model->id;
|
||||
$tagEntity->tag_id = $tag->id;
|
||||
$tagEntity->save();
|
||||
}
|
||||
|
||||
public function getInputs(string $entity, Model $model)
|
||||
|
Reference in New Issue
Block a user