first commit

This commit is contained in:
2023-11-21 19:51:44 +03:00
commit b87eb71ca7
254 changed files with 15630 additions and 0 deletions

3
console/config/.gitignore vendored Executable file
View File

@ -0,0 +1,3 @@
main-local.php
params-local.php
test-local.php

1
console/config/bootstrap.php Executable file
View File

@ -0,0 +1 @@
<?php

36
console/config/main.php Executable file
View File

@ -0,0 +1,36 @@
<?php
$params = array_merge(
require __DIR__ . '/../../common/config/params.php',
require __DIR__ . '/../../common/config/params-local.php',
require __DIR__ . '/params.php',
require __DIR__ . '/params-local.php'
);
return [
'id' => 'app-console',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'console\controllers',
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
],
'controllerMap' => [
'fixture' => [
'class' => \yii\console\controllers\FixtureController::class,
'namespace' => 'common\fixtures',
],
],
'components' => [
'log' => [
'targets' => [
[
'class' => \yii\log\FileTarget::class,
'levels' => ['error', 'warning'],
],
],
],
],
'params' => $params,
];

5
console/config/params.php Executable file
View File

@ -0,0 +1,5 @@
<?php
return [
'adminEmail' => 'admin@example.com',
];

4
console/config/test.php Executable file
View File

@ -0,0 +1,4 @@
<?php
return [
];

0
console/controllers/.gitkeep Executable file
View File

View File

@ -0,0 +1,33 @@
<?php
use yii\db\Migration;
class m130524_201442_init extends Migration
{
public function up()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
// https://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable('{{%user}}', [
'id' => $this->primaryKey(),
'username' => $this->string()->notNull()->unique(),
'auth_key' => $this->string(32)->notNull(),
'password_hash' => $this->string()->notNull(),
'password_reset_token' => $this->string()->unique(),
'email' => $this->string()->notNull()->unique(),
'status' => $this->smallInteger()->notNull()->defaultValue(10),
'created_at' => $this->integer()->notNull(),
'updated_at' => $this->integer()->notNull(),
], $tableOptions);
}
public function down()
{
$this->dropTable('{{%user}}');
}
}

View File

@ -0,0 +1,16 @@
<?php
use \yii\db\Migration;
class m190124_110200_add_verification_token_column_to_user_table extends Migration
{
public function up()
{
$this->addColumn('{{%user}}', 'verification_token', $this->string()->defaultValue(null));
}
public function down()
{
$this->dropColumn('{{%user}}', 'verification_token');
}
}

View File

@ -0,0 +1,31 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%table}}`.
*/
class m231012_102457_create_table_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%table}}', [
'id' => $this->primaryKey(),
'name' => $this->string(),
'places' => $this->integer(),
'type' => $this->string(),
'slug' => $this->string()
]);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('{{%table}}');
}
}

View File

@ -0,0 +1,35 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%product}}`.
*/
class m231012_102916_create_product_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%product}}', [
'id' => $this->primaryKey(),
'type' => $this->tinyInteger(),
'name' => $this->string(),
'description' => $this->string(),
'price' => $this->float(),
'status' => $this->tinyInteger(),
'quantity' => $this->integer(),
'taste' => $this->string(),
'strength' => $this->tinyInteger()
]);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('{{%product}}');
}
}

View File

@ -0,0 +1,31 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%category}}`.
*/
class m231017_091537_create_category_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%category}}', [
'id' => $this->primaryKey(),
'name' => $this->string(),
'description' => $this->string(),
'slug' => $this->string(),
]);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('{{%category}}');
}
}

View File

@ -0,0 +1,50 @@
<?php
use yii\db\Migration;
/**
* Handles adding columns to table `{{%product}}`.
*/
class m231017_112159_add_category_id_column_to_product_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('product', 'category_id', $this->integer());
$this->createIndex(
'idx-product-category_id',
'product',
'category_id'
);
$this->addForeignKey(
'fk-product-category_id',
'product',
'category_id',
'category',
'id',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey(
'fk-product-category_id',
'product'
);
$this->dropIndex(
'idx-product-category_id',
'product'
);
$this->dropColumn('product', 'category_id');
}
}

View File

@ -0,0 +1,68 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%order}}`.
*/
class m231019_110637_create_order_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%order}}', [
'id' => $this->primaryKey(),
'user_id' => $this->integer(),
'table_id' => $this->integer(),
'strength' => $this->tinyInteger(),
'amount' => $this->float(),
'status' => $this->tinyInteger(),
'created_at' => $this->timestamp(),
'updated_at' => $this->timestamp(),
]);
$this->createIndex(
'idx-order-user_id',
'order',
'user_id'
);
$this->addForeignKey(
'fk-order-user_id',
'order',
'user_id',
'user',
'id',
'CASCADE'
);
$this->createIndex(
'idx-order-table_id',
'order',
'table_id'
);
$this->addForeignKey(
'fk-order-table_id',
'order',
'table_id',
'table',
'id',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('fk-order-user_id', 'order');
$this->dropIndex('idx-order-user_id', 'order');
$this->dropForeignKey('fk-order-table_id', 'order');
$this->dropIndex('idx-order-table_id', 'order');
$this->dropTable('{{%order}}');
}
}

View File

@ -0,0 +1,63 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%order_product}}`.
*/
class m231019_123857_create_order_product_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%order_product}}', [
'id' => $this->primaryKey(),
'order_id' => $this->integer(),
'product_id' => $this->integer()
]);
$this->createIndex(
'idx-order_product-order_id',
'order_product',
'order_id'
);
$this->addForeignKey(
'fk-order_product-order_id',
'order_product',
'order_id',
'order',
'id',
'CASCADE'
);
$this->createIndex(
'idx-order_product-product_id',
'order_product',
'product_id'
);
$this->addForeignKey(
'fk-order_product-product_id',
'order_product',
'product_id',
'product',
'id',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('fk-order_product-order_id', 'order_product');
$this->dropIndex('idx-order_product-order_id', 'order_product');
$this->dropForeignKey('fk-order_product-product_id', 'order_product');
$this->dropIndex('idx-order_product-product_id', 'order_product');
$this->dropTable('{{%order_product}}');
}
}

View File

@ -0,0 +1,29 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%banner}}`.
*/
class m231023_142702_create_banner_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('{{%banner}}', [
'id' => $this->primaryKey(),
'photo' => $this->string(),
'rating' => $this->integer(),
]);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('{{%banner}}');
}
}

View File

@ -0,0 +1,25 @@
<?php
use yii\db\Migration;
/**
* Handles adding columns to table `{{%product}}`.
*/
class m231025_085405_add_photo_column_to_product_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('product', 'photo', $this->string());
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('product', 'photo');
}
}

1
console/models/.gitkeep Executable file
View File

@ -0,0 +1 @@
*

2
console/runtime/.gitignore vendored Executable file
View File

@ -0,0 +1,2 @@
*
!.gitignore