trabajando en el formulario de añadir

This commit is contained in:
2025-02-14 23:45:28 +01:00
parent b3cc82636d
commit a616ec7ba7
7 changed files with 225 additions and 50 deletions

View File

@ -11,18 +11,26 @@ class CreateTicketsSystem extends Migration
// Tabla de Categorías
$this->forge->addField([
'id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
'nombre' => ['type' => 'VARCHAR', 'constraint' => 100, 'unique' => true],
'keyword' => ['type' => 'VARCHAR', 'constraint' => 100, 'unique' => true],
]);
$this->forge->addPrimaryKey('id');
$this->forge->createTable('categorias');
$this->forge->createTable('tickets_categorias');
// Tabla de secciones
$this->forge->addField([
'id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
'keyword' => ['type' => 'VARCHAR', 'constraint' => 100, 'unique' => true],
]);
$this->forge->addPrimaryKey('id');
$this->forge->createTable('tickets_secciones');
// Tabla de Estados
$this->forge->addField([
'id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
'nombre' => ['type' => 'VARCHAR', 'constraint' => 100, 'unique' => true],
'keyword' => ['type' => 'VARCHAR', 'constraint' => 100, 'unique' => true],
]);
$this->forge->addPrimaryKey('id');
$this->forge->createTable('estados');
$this->forge->createTable('tickets_estados');
// Tabla de Tickets
$this->forge->addField([
@ -38,8 +46,8 @@ class CreateTicketsSystem extends Migration
]);
$this->forge->addPrimaryKey('id');
$this->forge->addForeignKey('usuario_id', 'users', 'id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('categoria_id', 'categorias', 'id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('estado_id', 'estados', 'id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('categoria_id', 'tickets_categorias', 'id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('estado_id', 'tickets_estados', 'id', 'CASCADE', 'CASCADE');
$this->forge->createTable('tickets');
// Tabla de Respuestas
@ -53,7 +61,7 @@ class CreateTicketsSystem extends Migration
$this->forge->addPrimaryKey('id');
$this->forge->addForeignKey('ticket_id', 'tickets', 'id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('usuario_id', 'users', 'id', 'CASCADE', 'CASCADE');
$this->forge->createTable('respuestas');
$this->forge->createTable('tickets_respuestas');
// Tabla de Adjuntos
$this->forge->addField([
@ -65,16 +73,16 @@ class CreateTicketsSystem extends Migration
]);
$this->forge->addPrimaryKey('id');
$this->forge->addForeignKey('ticket_id', 'tickets', 'id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('respuesta_id', 'respuestas', 'id', 'CASCADE', 'CASCADE');
$this->forge->createTable('adjuntos');
$this->forge->addForeignKey('respuesta_id', 'tickets_respuestas', 'id', 'CASCADE', 'CASCADE');
$this->forge->createTable('tickets_adjuntos');
}
public function down()
{
$this->forge->dropTable('adjuntos');
$this->forge->dropTable('respuestas');
$this->forge->dropTable('tickets_adjuntos');
$this->forge->dropTable('tickets_respuestas');
$this->forge->dropTable('tickets');
$this->forge->dropTable('categorias');
$this->forge->dropTable('estados');
$this->forge->dropTable('tickets_categorias');
$this->forge->dropTable('tickets_estados');
}
}

View File

@ -0,0 +1,60 @@
<?php
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
class TicketsSeeder extends Seeder
{
public function run()
{
// categorias
$data = [
[
'keyword' => 'errores',
],
[
'keyword' => 'consultas',
],
[
'keyword' => 'sugerencias',
],
];
$this->db->table('tickets_categorias')->insertBatch($data);
// secciones
$data = [
[
'keyword' => 'presupuestos',
],
[
'keyword' => 'pedidos',
],
[
'keyword' => 'facturacion',
],
[
'keyword' => 'logistica',
],
];
$this->db->table('tickets_secciones')->insertBatch($data);
// estados
$data = [
[
'keyword' => 'abierto',
],
[
'keyword' => 'en_proceso',
],
[
'keyword' => 'resuelto',
],
[
'keyword' => 'archivado',
],
];
$this->db->table('tickets_estados')->insertBatch($data);
}
}