door card pass: create table and create model and console controller
This commit is contained in:
29
console/controllers/DoorCardPassController.php
Normal file
29
console/controllers/DoorCardPassController.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace console\controllers;
|
||||
|
||||
use common\models\Card;
|
||||
use /** @noinspection PhpUnusedAliasInspection */
|
||||
Yii;
|
||||
use yii\console\Controller;
|
||||
|
||||
class DoorCardPassController extends Controller{
|
||||
|
||||
public function actionDenyAllCard( )
|
||||
{
|
||||
\Yii::$app->db->createCommand(Card::SQL_DENY_DOOR_CARD_PASS())->execute();
|
||||
}
|
||||
|
||||
public function actionAllowAllCard( )
|
||||
{
|
||||
\Yii::$app->db->createCommand(Card::SQL_ALLOW_DOOR_CARD_PASS())->execute();
|
||||
}
|
||||
|
||||
public function actionDenyExpiredCard( )
|
||||
{
|
||||
$now = date('Y-m-d H:i:s' );
|
||||
$now = time();
|
||||
\Yii::$app->db->createCommand(Card::SQL_DENY_DOOR_CARD_PASS_EXPIRED() ,['datetime'=> $now] )
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
||||
58
console/migrations/m230126_202055_create_table_door_card_pass.php
Executable file
58
console/migrations/m230126_202055_create_table_door_card_pass.php
Executable file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m230126_202055_create_table_door_card_pass
|
||||
*/
|
||||
class m230126_202055_create_table_door_card_pass extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$tableOptions = null;
|
||||
if ($this->db->driverName === 'mysql') {
|
||||
// http://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('door_card_pass',[
|
||||
'id_door_card_pass'=> $this->primaryKey(),
|
||||
'id_card' => $this->integer(11),
|
||||
'id_user' => $this->integer(11),
|
||||
'created_at' => $this->dateTime()->notNull(),
|
||||
'updated_at' => $this->dateTime()->notNull(),
|
||||
],
|
||||
$tableOptions
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
echo "m230126_202055_create_table_door_card_pass cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m230126_202055_create_table_door_card_pass cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
Reference in New Issue
Block a user