From 10899280b881356c47d9eb78598825d1346ec476 Mon Sep 17 00:00:00 2001 From: dozer111 Date: Wed, 12 Sep 2018 12:07:34 +0300 Subject: [PATCH] customer add create_at column --- common/models/Customer.php | 22 ++++++++++++++++++++-- console/migrations/m180912_090212_customer_add_update_at_column.php | 22 ++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 console/migrations/m180912_090212_customer_add_update_at_column.php diff --git a/common/models/Customer.php b/common/models/Customer.php index db98b41..eb244b8 100644 --- a/common/models/Customer.php +++ b/common/models/Customer.php @@ -4,6 +4,8 @@ use Yii; use yii\helpers\FileHelper; + use yii\behaviors\TimestampBehavior; + /** * This is the model class for table "customer". @@ -47,6 +49,9 @@ * * @property integer $working_lang * @property string $post_address ==> официальный почтовый адрес + * + * @property integer $created_at + * */ class Customer extends \yii\db\ActiveRecord { @@ -75,8 +80,21 @@ { return 'customer'; } - - /** + + + + public function behaviors() + { + return [ + [ + 'class' => TimestampBehavior::className(), + 'updatedAtAttribute' => false, + ], + ]; + } + + + /** * {@inheritdoc} */ public function rules() diff --git a/console/migrations/m180912_090212_customer_add_update_at_column.php b/console/migrations/m180912_090212_customer_add_update_at_column.php new file mode 100644 index 0000000..0a4b924 --- /dev/null +++ b/console/migrations/m180912_090212_customer_add_update_at_column.php @@ -0,0 +1,22 @@ +addColumn('customer', + 'created_at', + $this->integer()); + } + + public function down() + { + $this->dropColumn('customer','created_at'); + } + +} -- libgit2 0.21.4