mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
feat : chat migrations
This commit is contained in:
@ -13,9 +13,9 @@ class ChatsTable extends Migration
|
|||||||
"unsigned" => true,
|
"unsigned" => true,
|
||||||
"autoincrement" => true
|
"autoincrement" => true
|
||||||
],
|
],
|
||||||
"department" => [
|
"chat_department_id" => [
|
||||||
"type" => "VARCHAR",
|
"type" => "INT",
|
||||||
"constraint" => '255',
|
"unsigned" => true,
|
||||||
],
|
],
|
||||||
"pedido_id" => [
|
"pedido_id" => [
|
||||||
"type" => "INT",
|
"type" => "INT",
|
||||||
@ -50,13 +50,14 @@ class ChatsTable extends Migration
|
|||||||
]);
|
]);
|
||||||
$this->forge->addPrimaryKey('id');
|
$this->forge->addPrimaryKey('id');
|
||||||
$this->forge->addForeignKey('pedido_id', 'pedidos', 'id');
|
$this->forge->addForeignKey('pedido_id', 'pedidos', 'id');
|
||||||
$this->forge->createTable("chats");
|
// $this->forge->addForeignKey('chat_department_id', 'chat_departments', 'id');
|
||||||
|
$this->forge->createTable("chats",true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
$this->forge->dropTable("chats");
|
$this->forge->dropTable("chats",true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ class ChatDepartments extends Migration
|
|||||||
|
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$this->forge->createTable("chat_departments");
|
$this->forge->createTable("chat_departments",true);
|
||||||
$this->forge->addPrimaryKey('id');
|
$this->forge->addPrimaryKey('id');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,9 @@ class ChatMessages extends Migration
|
|||||||
"unsigned" => true,
|
"unsigned" => true,
|
||||||
|
|
||||||
],
|
],
|
||||||
|
"message" => [
|
||||||
|
"type" => "TEXT",
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
@ -48,7 +51,7 @@ class ChatMessages extends Migration
|
|||||||
|
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$this->forge->createTable("chat_messages");
|
$this->forge->createTable("chat_messages",true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@ class ChatDepartmentUsers extends Migration
|
|||||||
|
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$this->forge->createTable("chat_department_users");
|
$this->forge->createTable("chat_department_users",true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -45,4 +45,19 @@ class ChatModel extends Model
|
|||||||
protected $afterDelete = [];
|
protected $afterDelete = [];
|
||||||
|
|
||||||
|
|
||||||
|
public function getChat(int $chat_id)
|
||||||
|
{
|
||||||
|
$this->db->table('chats')
|
||||||
|
->select([
|
||||||
|
"chats.id as chatId",
|
||||||
|
"users.id as userId",
|
||||||
|
"users.email",
|
||||||
|
"chat_messages.created_at as messageCreatedAt",
|
||||||
|
"chat_messages.message as messageText",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
->join("users","users.id == chat_messages.user_id","left")
|
||||||
|
->join("chat_messages","chats.id == chat_messages.chat_id","left");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user