add superadmin dashboard. subscriptions
This commit is contained in:
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
/**
|
||||
* Migration для создания таблицы тарифов (plans)
|
||||
*/
|
||||
class AddPlansTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addField([
|
||||
'id' => [
|
||||
'type' => 'INT',
|
||||
'constraint' => 11,
|
||||
'unsigned' => true,
|
||||
'auto_increment' => true,
|
||||
],
|
||||
'name' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 100,
|
||||
'null' => false,
|
||||
],
|
||||
'description' => [
|
||||
'type' => 'TEXT',
|
||||
'null' => true,
|
||||
],
|
||||
'price' => [
|
||||
'type' => 'DECIMAL',
|
||||
'constraint' => '10,2',
|
||||
'default' => 0.00,
|
||||
],
|
||||
'currency' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 3,
|
||||
'default' => 'RUB',
|
||||
],
|
||||
'billing_period' => [
|
||||
'type' => 'ENUM',
|
||||
'constraint' => ['monthly', 'yearly', 'quarterly'],
|
||||
'default' => 'monthly',
|
||||
],
|
||||
'max_users' => [
|
||||
'type' => 'INT',
|
||||
'constraint' => 11,
|
||||
'default' => 5,
|
||||
],
|
||||
'max_clients' => [
|
||||
'type' => 'INT',
|
||||
'constraint' => 11,
|
||||
'default' => 100,
|
||||
],
|
||||
'max_storage' => [
|
||||
'type' => 'INT',
|
||||
'constraint' => 11,
|
||||
'default' => 10,
|
||||
],
|
||||
'features' => [
|
||||
'type' => 'JSON',
|
||||
'null' => true,
|
||||
],
|
||||
'is_active' => [
|
||||
'type' => 'TINYINT',
|
||||
'default' => 1,
|
||||
],
|
||||
'is_default' => [
|
||||
'type' => 'TINYINT',
|
||||
'default' => 0,
|
||||
],
|
||||
'created_at' => [
|
||||
'type' => 'DATETIME',
|
||||
'null' => false,
|
||||
],
|
||||
'updated_at' => [
|
||||
'type' => 'DATETIME',
|
||||
'null' => true,
|
||||
],
|
||||
]);
|
||||
|
||||
$this->forge->addKey('id', true);
|
||||
$this->forge->addUniqueKey(['name']);
|
||||
$this->forge->createTable('plans');
|
||||
|
||||
// Добавление базовых тарифов по умолчанию
|
||||
$seedData = [
|
||||
[
|
||||
'name' => 'Бесплатный',
|
||||
'description' => 'Базовый тариф для небольших команд',
|
||||
'price' => 0,
|
||||
'currency' => 'RUB',
|
||||
'billing_period' => 'monthly',
|
||||
'max_users' => 3,
|
||||
'max_clients' => 50,
|
||||
'max_storage' => 5,
|
||||
'features' => json_encode([
|
||||
'Базовые модули',
|
||||
'Email поддержка',
|
||||
'Экспорт в CSV',
|
||||
]),
|
||||
'is_active' => 1,
|
||||
'is_default' => 1,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
],
|
||||
[
|
||||
'name' => 'Старт',
|
||||
'description' => 'Тариф для растущих компаний',
|
||||
'price' => 990,
|
||||
'currency' => 'RUB',
|
||||
'billing_period' => 'monthly',
|
||||
'max_users' => 10,
|
||||
'max_clients' => 500,
|
||||
'max_storage' => 50,
|
||||
'features' => json_encode([
|
||||
'Все модули',
|
||||
'Приоритетная поддержка',
|
||||
'Экспорт в PDF и Excel',
|
||||
'API доступ',
|
||||
]),
|
||||
'is_active' => 1,
|
||||
'is_default' => 0,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
],
|
||||
[
|
||||
'name' => 'Бизнес',
|
||||
'description' => 'Полный функционал для крупных компаний',
|
||||
'price' => 4990,
|
||||
'currency' => 'RUB',
|
||||
'billing_period' => 'monthly',
|
||||
'max_users' => 50,
|
||||
'max_clients' => 5000,
|
||||
'max_storage' => 500,
|
||||
'features' => json_encode([
|
||||
'Все модули',
|
||||
'Персональный менеджер',
|
||||
'Экспорт в PDF и Excel',
|
||||
'Полный API доступ',
|
||||
'Интеграции',
|
||||
'Брендинг',
|
||||
]),
|
||||
'is_active' => 1,
|
||||
'is_default' => 0,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
],
|
||||
];
|
||||
|
||||
$this->db->table('plans')->insertBatch($seedData);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable('plans');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user