entyy_id add to tag migration

This commit is contained in:
Билай Станислав 2024-11-21 15:53:52 +03:00
parent 62eff81213
commit 1bc7662be0
11 changed files with 22 additions and 0 deletions

View File

@ -52,6 +52,8 @@ class TagModule extends Module
{
$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);

0
kernel/app_modules/tag/controllers/TagController.php Normal file → Executable file
View File

View File

@ -15,6 +15,7 @@ return new class extends Migration
$table->increments('id');
$table->string('label', 255)->nullable(false);
$table->string('entity', 255)->nullable(false);
$table->string('entity_id', 255)->nullable(false);
$table->string('slug', 255)->unique();
$table->integer('status')->default(1);
$table->timestamps();

1
kernel/app_modules/tag/models/Tag.php Normal file → Executable file
View File

@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Model;
* @property int $id
* @property string $label
* @property string $entity
* @property int $entity_id
* @property string $slug
* @property int $status
* @method static where(int[] $array)

1
kernel/app_modules/tag/models/forms/CreateTagForm.php Normal file → Executable file
View File

@ -12,6 +12,7 @@ class CreateTagForm extends FormModel
return [
'label' => 'required|min-str-len:5|max-str-len:30',
'entity' => 'required|min-str-len:1|max-str-len:50',
'entity_id' => 'required',
'slug' => '',
'status' => ''
];

0
kernel/app_modules/tag/routs/tag.php Normal file → Executable file
View File

2
kernel/app_modules/tag/services/TagService.php Normal file → Executable file
View File

@ -14,6 +14,7 @@ class TagService
$model = new Tag();
$model->label = $form_model->getItem('label');
$model->entity = $form_model->getItem('entity');
$model->entity_id = $form_model->getItem('entity_id');
$model->status = $form_model->getItem('status');
$model->slug = Slug::createSlug($form_model->getItem('label'), Tag::class);
if ($model->save()){
@ -30,6 +31,7 @@ class TagService
}
$tag->label = $form_model->getItem('label');
$tag->entity = $form_model->getItem('entity');
$tag->entity_id = $form_model->getItem('entity_id');
$tag->status = $form_model->getItem('status');
if ($tag->save()){

0
kernel/app_modules/tag/views/form.php Normal file → Executable file
View File

0
kernel/app_modules/tag/views/index.php Normal file → Executable file
View File

0
kernel/app_modules/tag/views/view.php Normal file → Executable file
View File

View File

@ -74,6 +74,13 @@ class AdminConsoleController extends ConsoleController
);
$this->out->r("create option active_modules", "green");
$this->optionService->createFromParams(
key: "entity_relations",
value: "{}",
label: "Свойства сущностей"
);
$this->out->r("create option entity_relations", "green");
$this->menuService->createItem([
"label" => "Модули",
"url" => "/admin",
@ -116,6 +123,14 @@ class AdminConsoleController extends ConsoleController
]);
$this->out->r("create item menu admin-themes", "green");
$this->menuService->createItem([
"label" => "Меню",
"url" => "/admin/settings/menu",
"slug" => "menu",
"parent_slug" => "settings"
]);
$this->out->r("create item menu admin-themes", "green");
$user = new CreateUserForm();
$user->load([
'username' => 'admin',