feat wiki/ayuda section

This commit is contained in:
amazuecos
2025-03-02 10:22:01 +01:00
parent 3406fb3005
commit 3140e527e8
24 changed files with 735 additions and 168 deletions

View File

@ -14,6 +14,11 @@ class WikiSectionsMigration extends Migration
'unsigned' => true,
'auto_increment' => true,
],
'order' => [
'type' => 'INT',
'unsigned' => true,
'null'=> true,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => 255,
@ -22,11 +27,6 @@ class WikiSectionsMigration extends Migration
'type' => 'VARCHAR',
'constraint' => 255,
],
'role' => [
'type' => 'VARCHAR',
'constraint' => 255,
'default' => 'admin'
],
'icon' => [
'type' => 'VARCHAR',
'constraint' => 255,

View File

@ -0,0 +1,60 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;
class WikiSectionRolesMigration extends Migration
{
protected array $COLUMNS = [
'id' => [
'type' => 'INT',
'unsigned' => true,
'auto_increment' => true,
],
'wiki_section_id' => [
'type' => 'INT',
'unsigned' => true,
],
'role' => [
'type' => 'VARCHAR',
'constraint' => 255,
'default' => 'admin'
],
];
public function up()
{
$this->forge->addField($this->COLUMNS);
$currenttime = new RawSql('CURRENT_TIMESTAMP');
$this->forge->addField([
'created_at' => [
'type' => 'TIMESTAMP',
'default' => $currenttime,
],
'updated_at' => [
'type' => 'TIMESTAMP',
'null' => true,
],
'deleted_at' => [
'type' => 'TIMESTAMP',
'null' => true,
],
]);
$this->forge->addPrimaryKey('id');
$this->forge->addForeignKey('wiki_section_id','wiki_sections','id');
$this->forge->createTable("wiki_section_roles");
}
public function down()
{
$this->forge->dropTable("wiki_section_roles");
}
}

View File

@ -4,102 +4,162 @@ namespace App\Database\Seeds;
use App\Models\Configuracion\ConfigVariableModel;
use App\Models\Wiki\WikiSectionModel;
use App\Models\Wiki\WikiSectionRoleModel;
use CodeIgniter\Database\Seeder;
class WikiSectionSeeder extends Seeder
{
protected array $dataAdmin = [
[
"name" => 'Introducción',
"slug" => 'intro-admin',
"icon" => 'ti ti-home-2'
[
"name" => 'Introducción',
"slug" => 'intro-admin',
"icon" => 'ti ti-home-2',
"roles" => [
"admin",
],
[
"name" => 'Presupuesto',
"slug" => 'presupuesto-admin',
"icon" => 'ti ti-currency-dollar'
],
[
"name" => 'Presupuesto',
"slug" => 'presupuesto-admin',
"icon" => 'ti ti-currency-dollar',
"roles" => [
"admin",
],
],
[
"name" => 'Pedidos',
"slug" => 'pedidos-admin',
"icon" => 'ti ti-file-description',
"roles" => [
"admin",
],
[
"name" => 'Pedidos',
"slug" => 'pedidos-admin',
"icon" => 'ti ti-file-description'
],
[
"name" => 'Facturación',
"slug" => 'facturacion-admin',
"icon" => 'ti ti-file-dollar',
"roles" => [
"admin",
],
[
"name" => 'Facturación',
"slug" => 'facturacion-admin',
"icon" => 'ti ti-file-dollar'
],
[
"name" => 'Logística',
"slug" => 'logistica-admin',
"icon" => 'ti ti-truck',
"roles" => [
"admin",
],
[
"name" => 'Logística',
"slug" => 'logistica-admin',
"icon" => 'ti ti-truck'
],
[
"name" => 'Tarifas',
"slug" => 'tarifas-admin',
"icon" => 'ti ti-receipt',
"roles" => [
"admin",
],
[
"name" => 'Tarifas',
"slug" => 'tarifas-admin',
"icon" => 'ti ti-receipt'
],
[
"name" => 'Configuración',
"slug" => 'config-admin',
"icon" => 'ti ti-adjustments-horizontal',
"roles" => [
"admin",
],
[
"name" => 'Configuración',
"slug" => 'config-admin',
"icon" => 'ti ti-adjustments-horizontal'
],
[
"name" => 'Mensajería',
"slug" => 'messages-admin',
"icon" => 'ti ti-message',
"roles" => [
"admin",
],
[
"name" => 'Mensajería',
"slug" => 'messages-admin',
"icon" => 'ti ti-message'
]
]
];
protected array $dataCliente = [
[
"name" => 'Introducción',
"slug" => 'intro-cliente',
"icon" => 'ti ti-home-2',
"roles" => [
"cliente-admin",
"cliente-editor",
]
],
[
"name" => 'Presupuesto(Cliente)',
"slug" => 'presupuesto-cliente',
"role" => 'cliente',
"icon" => 'ti ti-currency-dollar',
"role" => 'cliente',
"roles" => [
"cliente-admin",
"cliente-editor",
]
],
[
"name" => 'Pedidos(Cliente)',
"slug" => 'pedidos-cliente',
"icon" => 'ti ti-file-description',
"role" => 'cliente',
"roles" => [
"cliente-admin",
"cliente-editor",
]
],
[
"name" => 'Facturación (Cliente)',
"slug" => 'facturacion-cliente',
"icon" => 'ti ti-file-dollar',
"role" => 'cliente',
"roles" => [
"cliente-admin",
"cliente-editor",
]
],
[
"name" => 'Tarifas (Cliente)',
"slug" => 'tarifas-cliente',
"icon" => 'ti ti-receipt',
"role" => 'cliente',
"roles" => [
"cliente-admin",
"cliente-editor",
]
],
[
"name" => 'Mensajería (Cliente)',
"slug" => 'messages-cliente',
"icon" => 'ti ti-message',
"role" => 'cliente',
"roles" => [
"cliente-admin",
"cliente-editor",
]
]
];
];
public function run()
{
$wikiSectionModel = model(WikiSectionModel::class);
$wikiSectionRoleModel = model(WikiSectionRoleModel::class);
$section_order = 0;
foreach ($this->dataAdmin as $key => $row) {
# code...
$wikiSectionModel->insert($row);
$row['order'] = $section_order;
$wikiSectionId = $wikiSectionModel->insert($row);
$section_order++;
foreach ($row['roles'] as $key => $role) {
$wikiSectionRoleModel->insert(['wiki_section_id' => $wikiSectionId,"role" => $role]);
}
}
foreach ($this->dataCliente as $key => $row) {
# code...
$wikiSectionModel->insert($row);
$row['order'] = $section_order;
$wikiSectionId = $wikiSectionModel->insert($row);
$section_order++;
foreach ($row['roles'] as $key => $role) {
$wikiSectionRoleModel->insert(['wiki_section_id' => $wikiSectionId,"role" => $role]);
}
}
}
}