api
This commit is contained in:
26
console/controllers/SwaggerController.php
Normal file
26
console/controllers/SwaggerController.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace console\controllers;
|
||||
|
||||
use OpenApi\Annotations\OpenApi;
|
||||
use yii\console\Controller;
|
||||
use Yii;
|
||||
use yii\console\ExitCode;
|
||||
use yii\helpers\Console;
|
||||
|
||||
|
||||
class SwaggerController extends Controller
|
||||
{
|
||||
|
||||
public function actionGo()
|
||||
{
|
||||
$openApi = \OpenApi\Generator::scan([Yii::getAlias("@frontend/modules/api")]);
|
||||
$file = Yii::getAlias('@frontend/web/api-doc/dist/swagger.yaml');
|
||||
$handle = fopen($file, 'wb');
|
||||
fwrite($handle, $openApi->toYaml());
|
||||
fclose($handle);
|
||||
echo $this->ansiFormat('Created \n", Console::FG_BLUE');
|
||||
return ExitCode::OK;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m240507_141733_add_category_id_column_at_product_table
|
||||
*/
|
||||
class m240507_141733_add_category_id_column_at_product_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->addColumn('product', 'product_category_id', $this->integer(11)->defaultValue(0)->notNull());
|
||||
|
||||
$this->createIndex('idx-product-product_category_id', 'product', 'product_category_id');
|
||||
|
||||
$this->addForeignKey(
|
||||
'fk-product-product_category_id',
|
||||
'product',
|
||||
'product_category_id',
|
||||
'product_category',
|
||||
'id',
|
||||
'CASCADE'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey(
|
||||
'fk-product-product_category_id',
|
||||
'product'
|
||||
);
|
||||
|
||||
// drops index for column `author_id`
|
||||
$this->dropIndex(
|
||||
'idx-product-product_category_id',
|
||||
'product'
|
||||
);
|
||||
|
||||
$this->dropColumn('product', 'product_category_id');
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m240507_141733_add_category_id_column_at_product_table cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
Reference in New Issue
Block a user