door card pass: create table and create model and console controller

This commit is contained in:
Schneider Roland
2023-02-08 19:42:42 +01:00
parent 3daa39a0b6
commit 4d44b1c2af
9 changed files with 307 additions and 19 deletions

View 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();
}
}

View 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;
}
*/
}